Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.03 seconds.

  1. Replies
    24
    Views
    5,106

    Spaces in a file name need to be escaped or...

    Spaces in a file name need to be escaped or quoted when used in a shell. Do you consider spaces to be "unsafe"? Are spaces "special"?



    Why would my age matter? I've been putting spaces in file...
  2. Replies
    24
    Views
    5,106

    OK, but I still don't understand what you mean by...

    OK, but I still don't understand what you mean by "safe". All characters that you might find in a file name are "safe" (otherwise the OS wouldn't have let you use them in a file name in the first...
  3. Replies
    24
    Views
    5,106

    Are you renaming the files themselves, or just...

    Are you renaming the files themselves, or just displaying their names in some sort of user interface? If the former, I'd be careful not to overwrite existing files. For example, if you have two files...
  4. I'm pretty sure delete this in a class's...

    I'm pretty sure delete this in a class's destructor will cause problems. What happens if an instance of the class was statically or automatically allocated? You can't delete it. And if it's...
  5. Replies
    24
    Views
    5,106

    But strspn returns 1 only when the first...

    But strspn returns 1 only when the first character is special and the next character is not special. So strspn("##foo", SPECIAL_CHARS) will return 2.

    strspn and strcspn are the wrong tools for...
  6. Replies
    8
    Views
    3,674

    But that requires that you assume how sem_t is...

    But that requires that you assume how sem_t is defined. POSIX doesn't say how the sem_t structure is defined. A semaphore with a value of 0 might be valid. On the other hand, a null pointer to a...
  7. Replies
    8
    Views
    3,674

    typedef sem_t *npawsem; #define INVALID SEM NULL...

    typedef sem_t *npawsem;
    #define INVALID SEM NULL


    Then make a function to allocate (with malloc() or shmget() or shm_open() or whatever, depending on how it's shared) and initialize (with...
  8. In other words, the compiler you used (GCC?) is...

    In other words, the compiler you used (GCC?) is smart enough to optimize the recursive code to the equivalent to this code:



    int divide(int a)
    {
    if (a > 1) {
    return 1;
    }
    ...
  9. Replies
    27
    Views
    8,209

    Tail call optimization isn't a guaranteed feature...

    Tail call optimization isn't a guaranteed feature of C. Many compilers can do it, but you can't count on it in general.
  10. Replies
    2
    Views
    2,352

    To be clear, (++x)*(++x) is undefined behavior...

    To be clear, (++x)*(++x) is undefined behavior because you cannot modify the same object more than once between sequence points. You can't and shouldn't expect any particular result from undefined...
  11. Replies
    17
    Views
    11,311

    Interesting, and I stand corrected. But it...

    Interesting, and I stand corrected.

    But it seems the C standard implies that char is always one byte, whether it's 8 bits or 16 bits or 32 bits, since the size of every type is measured against...
  12. Replies
    17
    Views
    11,311

    One nitpick: sizeof reports the size of an object...

    One nitpick: sizeof reports the size of an object or type in terms of the size of a char, not bytes. A char is one byte on most platforms, but some platforms may define char as 16 or 32 bits (in...
  13. Replies
    17
    Views
    11,311

    I disagree for the most part. A beginner...

    I disagree for the most part.

    A beginner programmer shouldn't really worry about how big each data type is (they should understand their ranges and when and where to use each type, though). And by...
  14. Replies
    6
    Views
    6,103

    Yeah, that has always irked me. But to be fair to...

    Yeah, that has always irked me. But to be fair to the original stdio designers, they created it long before the convention existed to put the object parameter first.
  15. Replies
    5
    Views
    4,561

    "toupper" (note the "u") is in ctype.h, but...

    "toupper" (note the "u") is in ctype.h, but strchr is in string.h.
  16. Replies
    6
    Views
    6,103

    Since you aren't worried about exactly following...

    Since you aren't worried about exactly following C++ method-calling syntax, why not just call the methods directly without a "method_call" macro?

    So instead of this:



    method_call...
  17. Replies
    17
    Views
    11,311

    What you should do instead of hardcoding the size...

    What you should do instead of hardcoding the size of int as 4 (int is larger or smaller than 4 on some platforms) is to use sizeof (int), or better yet, sizeof array[0]:



    unsigned int size...
  18. Replies
    17
    Views
    5,932

    Doesn't answer the question of how namespaces are...

    Doesn't answer the question of how namespaces are flawed. Your insistence on using a class where a namespace is more appropriate, however, has already been addressed by an answer to a Stack Overflow...
  19. Replies
    17
    Views
    5,932

    Packages in Java and the namespace keyword in C++...

    Packages in Java and the namespace keyword in C++ both implement the "idea" of namespaces, which you implied is flawed:



    Or do you mean something else?

    If you only mean that "namespace" in...
  20. Replies
    17
    Views
    5,932

    ??? I'm thinking there might be a language...

    ???

    I'm thinking there might be a language barrier here. "Judgment", as laserlight used the word, means (from a quick Google search on its definition) "the ability to make considered decisions or...
  21. Replies
    9
    Views
    2,086

    Yes (if and only if the object is no longer...

    Yes (if and only if the object is no longer needed). Who said otherwise?



    C# isn't really relevant here, though. This thread seems to be about the ol' Win32 UI API in C++.
  22. Replies
    17
    Views
    5,932

    Clearly you could care less as you do care at...

    Clearly you could care less as you do care at least a little about them. (If you cared not a whit about them then that means you couldn't care less about them, and you wouldn't be posting about them...
  23. Replies
    9
    Views
    2,086

    1. Since this thread is specifically about...

    1. Since this thread is specifically about Windows UI programming, whose API is in C, there is no C++ destructor for UI objects. You could wrap part of the Windows UI API in C++ objects so that...
  24. Replies
    9
    Views
    2,086

    The object does not exist anymore after the...

    The object does not exist anymore after the free() call. The memory previously used by the object still exists, of course, but it's not allocated to anything at that point (it's free, unallocated...
  25. Replies
    17
    Views
    5,932

    But why would you put functions in a namespace if...

    But why would you put functions in a namespace if they're not shared with other source files? (That is, if they're all static (file-local) functions then why do they need to be in a namespace?)
    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4