Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.14 seconds; generated 49 minute(s) ago.

  1. True, but dserver in post #1 is a static local...

    True, but dserver in post #1 is a static local variable, so it will be zero initialised at startup.
  2. Salem's suggestion is effectively a Meyer's...

    Salem's suggestion is effectively a Meyer's singleton, if you want to do further reading.
  3. Replies
    7
    Views
    125

    Break up your main functions into smaller...

    Break up your main functions into smaller functions that each does one thing and does it well.

    DRY principle: Don't Repeat Yourself. If you do the same thing in multiple places, try to pull it out...
  4. Replies
    11
    Views
    167

    Why are you generating the random integer 20...

    Why are you generating the random integer 20 times, overwriting it each time except the last? You only need to generate it once, although I'm guessing you want the for loop to include more than just...
  5. Replies
    11
    Views
    167

    It looks like you still have that semi-colon...

    It looks like you still have that semi-colon terminating the for loop early. You need to use braces to mark the body of the for loop because it consists of more than one statement.
  6. Replies
    11
    Views
    167

    What is your current code? Post it within code...

    What is your current code? Post it within code tags.
  7. Replies
    11
    Views
    225

    The formal names are "lvalue reference" and...

    The formal names are "lvalue reference" and "rvalue reference" :)

    Universal references don't exist in the semantics of C++, but rather is useful to refer to syntax involving && with some deduced...
  8. Replies
    2
    Views
    152

    If we exclude possible implementation-specific...

    If we exclude possible implementation-specific bugs, no.
  9. Replies
    11
    Views
    225

    Unfortunately the formerly best book for learning...

    Unfortunately the formerly best book for learning standard C++, Accelerated C++, is indeed an old book that hasn't been updated by Koenig and Moo for C++11. That said, if it's available at your local...
  10. Replies
    7
    Views
    372

    What's the reason behind the doubled parentheses?...

    What's the reason behind the doubled parentheses? It doesn't look like there's a precedence pitfall to avoid.
  11. Replies
    3
    Views
    241

    Can't you change the main program to open the...

    Can't you change the main program to open the file, read and store the data, and then pass it to UMAT on each call?


    Yes, that is what I mean, assuming you only need an int rather than some...
  12. Replies
    4
    Views
    282

    It might be helpful to understand typedefs the...

    It might be helpful to understand typedefs the way the standard sees them: a typedef is a declaration of identifiers that has the storage class specifier of typedef. So you should ask yourself, what...
  13. Replies
    3
    Views
    241

    By "user subroutine" do you mean "function"? That...

    By "user subroutine" do you mean "function"? That would be the standard term in C.

    If so, it sounds like you should open the file in the calling function. If you cannot do that, then you might...
  14. That's only true if you know for sure that the...

    That's only true if you know for sure that the input ends in digits only.


    If you want to print to standard output, printf is fine. It was your use of it that was problematic. You could have...
  15. It's not just a security issue, it's a potential...

    It's not just a security issue, it's a potential bug even under normal usage by a trusted user: if the string accidentally is constructed to contain a format specification, the behaviour is then...
  16. I was thinking along the lines of: char...

    I was thinking along the lines of:

    char *extract_consecutive_digits(const char *input, char *output, size_t output_size)
    {
    const char *digits = input + strcspn(input, "0123456789");
    ...
  17. Write a function to extract the digits in a...

    Write a function to extract the digits in a string. Test it. After you are sure, you can then use this function on the lines of your text file by reading them as strings.
  18. As per rstanley's firm insistence, please stick...

    As per rstanley's firm insistence, please stick to standard C, and hence ignore flp1969's post #2. Both poll and select are non-standard with respect to C11.

    Besides Click_here's mention about EOF...
  19. Replies
    10
    Views
    428

    I didn't suggest using system; I suggested using...

    I didn't suggest using system; I suggested using sed. There is no need to write a C program that calls system to invoke sed. Just invoke sed. If you do have other things to do that would be...
  20. I'm inclined to count the number of 0s (call this...

    I'm inclined to count the number of 0s (call this N), then count the number of 1s (call this M) in the first N elements of the array. M is the minimum number of swaps required. This is more of an...
  21. Replies
    10
    Views
    428

    Yes. However, instead of doing this in C, you...

    Yes. However, instead of doing this in C, you might want to do this using sed if it is available.
  22. Replies
    3
    Views
    299

    Is there any code that you aren't showing us? Put...

    Is there any code that you aren't showing us? Put it another way: is this the entire content of the main function?
  23. I believe the tag namespace is separate, so...

    I believe the tag namespace is separate, so struct cgraph_node would not conflict with a function named cgraph_node. On the other hand, perhaps it would be a better idea to use a different function...
  24. Replies
    1
    Views
    113

    Instead of trying to do early detection, accept...

    Instead of trying to do early detection, accept that disk failures happen and so get a NAS or cloud storage and auto-backup to it.
  25. Replies
    2
    Views
    254

    I use my B&W laser printer once every couple of...

    I use my B&W laser printer once every couple of months with no toner issues.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4