Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.16 seconds; generated 34 minute(s) ago.

  1. Yes. Alternatively, you can pass a second pointer...

    Yes. Alternatively, you can pass a second pointer that points to one past the end of the range that you want the function to access. Yet another possibility is that it may make sense to wrap both the...
  2. Replies
    9
    Views
    157

    I didn't say fread doesn't read from stdin's...

    I didn't say fread doesn't read from stdin's buffer; I said that fread doesn't read from its own buffer. It's true that I carefully avoided using the phrase "stdin's buffer", and that's because...
  3. Replies
    9
    Views
    157

    No, as you correctly wrote later, it reads from...

    No, as you correctly wrote later, it reads from stdin into its own buffer.


    What exactly fread does is implementation defined by definition, but for efficiency it's likely to read in chunks of...
  4. Replies
    9
    Views
    157

    No. fread reads from stdin into its own buffer....

    No. fread reads from stdin into its own buffer. It is likely implemented using operating system specific API calls (and is meant to handle binary data, not just text), but you can imagine it being...
  5. Replies
    9
    Views
    157

    fread has its own buffer, i.e., the memory of the...

    fread has its own buffer, i.e., the memory of the objects that you are trying to read into. So, fread doesn't have to read everything at once, and so it doesn't have to know beforehand how many...
  6. I guess upgrading compiler isn't an option then...

    I guess upgrading compiler isn't an option then :)

    Unfortunately in your real code, this could be due to undefined behaviour interacting with compiler optimisation, rather than a compiler bug. But...
  7. What version of gcc did you use to compile?

    What version of gcc did you use to compile?
  8. Since it is impossible to assign to 0, I'm...

    Since it is impossible to assign to 0, I'm guessing you mean the opposite, that is, this line?

    buffer[strcspn(buffer,"\n")] = 0;
    If so, that's weird: the statement is not a candidate to be...
  9. Replies
    8
    Views
    185

    Doing that reinterprets an object of one type as...

    Doing that reinterprets an object of one type as being of another type via pointers, and isn't what you want here. What you're probably thinking of is a pointer to void, but that is not type safe,...
  10. No. Since q is a parameter, it is assigned a...

    No. Since q is a parameter, it is assigned a value every time the function is called, i.e., its value is the corresponding argument passed to the function.


    foo(x) is an expression that means a...
  11. Replies
    15
    Views
    220

    You cannot implicitly convert a pointer to a...

    You cannot implicitly convert a pointer to a String to a reference to a String; that's why you need to dereference the pointer to get a String object for the String reference to refer to.


    Just...
  12. Replies
    8
    Views
    185

    I think that this is the fundamental problem: you...

    I think that this is the fundamental problem: you should make Player a polymorphic base class, defining a common interface that Knight and Cowboy can both implement, and which will be used by the...
  13. Replies
    15
    Views
    220

    If all you want to do is avoid a possible copy...

    If all you want to do is avoid a possible copy constructor call, then indeed the second example is better (if you return *string instead), but it is also so error-prone that you should live with the...
  14. Replies
    8
    Views
    185

    A few stylistic issues to address: [list] You...

    A few stylistic issues to address:
    [list]
    You didn't provide the code that shows what are the types involved, but I'm going to guess that CowboyPtr and WeaponPtr are just typedefs for Cowboy* and...
  15. I think when the requirements ask for you to pass...

    I think when the requirements ask for you to pass multiple time structs, they mean multiple objects (or pointers thereof) of the same time struct type, not three time struct types that are identical...
  16. Replies
    4
    Views
    542

    C11 only specifies these encoding prefixes for...

    C11 only specifies these encoding prefixes for string literals: u8, u, U, L. Hence, your b# and B# encoding prefixes would not conflict as a language extension.

    The syntax specified by the...
  17. Thread: Slow forum?

    by laserlight
    Replies
    11
    Views
    483

    Seems to be working for now.

    Seems to be working for now.
  18. What do you think is the problem and what have...

    What do you think is the problem and what have you tried for debugging, e.g., have you stepped through the loop with a debugger?
  19. That's because the smallest number is indeed 0....

    That's because the smallest number is indeed 0. Notice that you declared the array as having 8 int values, then initialised it with 7 int literals. Therefore, the remaining element in the array is 0,...
  20. Replies
    13
    Views
    213

    You probably want to print element instead of...

    You probably want to print element instead of vector.

    Btw, instead of just saying "it does not compile", post the compile error.
  21. Replies
    13
    Views
    213

    You should be aware that as there is increasing...

    You should be aware that as there is increasing support for templates and declaring stuff to be inline, it has also become more common for libraries (and hence C++ programs in general) to become...
  22. Replies
    13
    Views
    213

    Place it in a header that is included by the...

    Place it in a header that is included by the other headers; remember to use inclusion guards.
  23. Replies
    1
    Views
    121

    I'd start by indenting your code consistently:...

    I'd start by indenting your code consistently: every time control enters the body of a function, if statement, loop, indent by one level. Every it exits the body of that construct, decrease the...
  24. Replies
    5
    Views
    319

    No, that was not what you were trying to do. If...

    No, that was not what you were trying to do. If it was, then mysql_real_escape_string would be wrong because it escapes strings for use as string values in an SQL statement. It doesn't escape values...
  25. Another possibility is that you have already...

    Another possibility is that you have already written the program but couldn't get it to compile on the MinGW port of g++. Is this the case, and if so, what did you try and what errors did you...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4