Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.15 seconds; generated 39 minute(s) ago.

  1. Not necessarily. If you do not provide an...

    Not necessarily. If you do not provide an initialiser, then the variable would be zero initialised if it has static storage duration, i.e., if it was declared at file scope or declared static in a...
  2. Ah, right. I'm afraid that nikosant03's...

    Ah, right.

    I'm afraid that nikosant03's example is not very good though:

    It makes use of global variables without good reason. (Well, this program is sufficiently trivial that the use of...
  3. In the function named average, you forgot to...

    In the function named average, you forgot to initialise sum and count to 0.
  4. I think the question has an error: it requests...

    I think the question has an error: it requests for the "average of even numbers", but provides sample input that results in sample output that is the sum of even numbers.
  5. Replies
    1
    Views
    65

    What I'd do is declare a struct consisting of a...

    What I'd do is declare a struct consisting of a member that stores the line and another member that stores the average value. Then I can populate an array of these struct objects and sort it...
  6. It would be good for you to provide an example of...

    It would be good for you to provide an example of such a container class and its associated documentation for readers here to examine since it is possible that you may have misinterpreted the claim,...
  7. Replies
    3
    Views
    193

    You might want to elaborate on this. For example,...

    You might want to elaborate on this. For example, by "set" you presumably mean a set of values on a line. Do you want to sort the values within each set? Do you want to sort the sets themselves with...
  8. Replies
    1
    Views
    142

    You need to construct the filename from the...

    You need to construct the filename from the command line argument, e.g., by creating an array of char large enough to hold the result, then copying the command line argument followed by ".txt".
  9. It sounds like this is the problem text rather...

    It sounds like this is the problem text rather than a paraphrase: "The numbers must be separated from other words by at least one whitespace."

    If so, "word" in this context is used to mean...
  10. Yes, and of the same type.

    Yes, and of the same type.
  11. This: (&x)[i] is equivalent to: *(&x + i)...

    This:

    (&x)[i]
    is equivalent to:

    *(&x + i)
    Suppose i == 0, then we end up with:

    *(&x + 0)
    which is equivalent to:
  12. Instead of parsing the number yourself, I wonder...

    Instead of parsing the number yourself, I wonder if it will be easier to "cheat" by replacing the comma, if one exists, with a period, then calling something like strtod.
  13. Declare the array in the caller and pass a...

    Declare the array in the caller and pass a pointer to the array as an argument when calling the function. It is also wise to have a parameter for the size of the array.

    Alternatively, you can use...
  14. Post in a new thread since it is unrelated.

    Post in a new thread since it is unrelated.
  15. Replies
    4
    Views
    163

    What is the version of g++ that you're using? I...

    What is the version of g++ that you're using? I believe g++ has defaulted to C++11 or later for a few major versions now, e.g., a quick check shows g++ 6.5 will default to the GNU dialect of C++14.
  16. Oh, but that wouldn't help you understand the...

    Oh, but that wouldn't help you understand the code flow, if by that you mean the flow of control through the program. That would be done by tracing function call graphs rather than by finding all...
  17. Replies
    4
    Views
    163

    Wait, so you're not compiling with respect to...

    Wait, so you're not compiling with respect to C++11 or later?
  18. Why do you want to find all calls of that method?...

    Why do you want to find all calls of that method? Usually I'd imagine it is to perform a rename, and your IDE may have a specific refactoring tool for that, but then indirect invocation of the method...
  19. Replies
    8
    Views
    212

    That's what I had in mind when I wrote that "just...

    That's what I had in mind when I wrote that "just that certain implementations may permit it for their own use cases".


    No, just assigning an arbitrary address without doing pointer arithmetic is...
  20. Replies
    8
    Views
    212

    The rule that you might be thinking of is the one...

    The rule that you might be thinking of is the one about pointer arithmetic with respect to the elements of an array: in such a case the standard defines addition of an integer to a pointer such that...
  21. Replies
    19
    Views
    497

    On the contrary, you do have to declare variables...

    On the contrary, you do have to declare variables before assigning to them (or from them, for that matter).

    Anyway, the reason why john.c is facepalming so hard is that the tutorial that Salem was...
  22. Replies
    19
    Views
    497

    oods1, do you have a computer programming...

    oods1, do you have a computer programming background, and are you familiar with the C programming language?
  23. Replies
    3
    Views
    199

    If you're willing to use the non-standard but...

    If you're willing to use the non-standard but POSIX-standard getline function, then life is somewhat easier:

    char *line = NULL;
    size_t len = 0;
    if (getline(&line, &len, stdin) != -1)
    {
    //...
  24. No, let's take a look at this line: ...

    No, let's take a look at this line:

    *(ptr_arr+i) = word;
    it would be slightly easier if we transformed it to use array notation:

    ptr_arr[i] = word;
    ptr_arr[i] is an int, whereas word is a...
  25. Replies
    8
    Views
    291

    I would start by defining a function to print a...

    I would start by defining a function to print a single employee's data:

    void print_employee(FILE *fp, const Employee *employee);
    I would manually create an Employee object and test this...
Results 1 to 25 of 497
Page 1 of 20 1 2 3 4