Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.12 seconds; generated 6 minute(s) ago.

  1. Replies
    1
    Views
    35

    In this context, i.e., when they are used...

    In this context, i.e., when they are used standalone, there is effectively no difference. The differences only matter when they are used as part of a larger expression.
  2. Replies
    3
    Views
    46

    It stores the address of the structure object. ...

    It stores the address of the structure object.

    This address is the same in value as one of the members of the struct object (i.e., the first) because the struct object consists of these members,...
  3. Replies
    6
    Views
    93

    "excess elements in array initializer" sounds...

    "excess elements in array initializer" sounds pretty straightforward: you're trying to initialise the array with too many elements. For example, in this case you declared the array as an...
  4. Replies
    2
    Views
    76

    Search the Web for a JSON parser for C++

    Search the Web for a JSON parser for C++
  5. Almost. To be consistent, the last printf should...

    Almost. To be consistent, the last printf should be:

    printf(" n = %p \n", n);
    Also, technically the argument corresponding to %p should be a void*, so you may see:

    printf(" n = %p \n",...
  6. Look at this example that you yourself wrote: ...

    Look at this example that you yourself wrote:

    int fun ( int *p )
    {
    *p = 20;

    return p;
    }
    Here is the same function, but with the place in the syntax where the return type is...
  7. Check the return type of the function. Is it a...

    Check the return type of the function. Is it a pointer type? If yes, then the function returns a pointer.
  8. Replies
    6
    Views
    105

    At the top of foo.c, declare x: extern int x;...

    At the top of foo.c, declare x:

    extern int x;

    You also need to #include <stdio.h> in foo.c
  9. Only mathematically. In this context, 20 is an...

    Only mathematically. In this context, 20 is an int, whereas 0061FF28 is an address (i.e., the value of a pointer). The function is declared as returning an int, not a pointer.


    Since you want to...
  10. Replies
    6
    Views
    105

    Yes, a global variable indeed has global scope,...

    Yes, a global variable indeed has global scope, i.e., every use of that name that has not been shadowed by another variable whose name has a more local scope refers to that global variable.
  11. Replies
    4
    Views
    126

    "Hello" is a string constant because it is a...

    "Hello" is a string constant because it is a string constant by definition. Likewise, in this program below, 123 is an integer constant because it is an integer constant by definition, no const...
  12. Replies
    4
    Views
    126

    "Hello" is a string constant, so it exists...

    "Hello" is a string constant, so it exists independently of the pointer.
  13. Replies
    5
    Views
    195

    The simple answer is that you're looking at the...

    The simple answer is that you're looking at the effects of undefined behaviour because accessing an array out of bounds is undefined behaviour. Going deeper, it could be that you were modifying other...
  14. Replies
    2
    Views
    77

    You need to call the function through the...

    You need to call the function through the function pointer:

    (*execute)();
    It should also be possible to omit the explicit dereference as a form of syntactic sugar:

    execute();
  15. Replies
    5
    Views
    195

    Your idea of creating a new dynamic array and...

    Your idea of creating a new dynamic array and copying over the old one to it each time you add a grade is rather expensive: instead of taking amortised constant time, addGrade will take linear time,...
  16. Replies
    43
    Views
    675

    Think about picking one of four restaurants to...

    Think about picking one of four restaurants to eat at for lunch using a single roll of a six-sided die: if you use the entire range of the die using modulo, then two of the restaurants will be twice...
  17. Replies
    43
    Views
    675

    The code desperately needs to be formatted...

    The code desperately needs to be formatted properly and use descriptive variable names where appropriate, and possibly broken up into smaller functions that do one thing and do it well.

    But more...
  18. * moved to Tech Board *

    * moved to Tech Board *
  19. After you replace "class" with "struct", it's...

    After you replace "class" with "struct", it's even simpler because friendship, references, and parents don't exist in C, and you don't have to worry about the case where a member function that is...
  20. Perhaps you meant to say that you're supposed to...

    Perhaps you meant to say that you're supposed to print a sequence, presumably of variable length? If so, one simple solution is to save the initial number in a separate variable, then after using the...
  21. Replies
    9
    Views
    163

    If you're having difficulty understanding K&R,...

    If you're having difficulty understanding K&R, then put it aside for now and reach for a beginner's introductory book rather than an experienced programmer's introductory book.


    What does the...
  22. Replies
    9
    Views
    163

    The pointer is named v. C programmers often...

    The pointer is named v.


    C programmers often loosely use the word "struct" or "structure" to mean an object of struct type. In your example, there is no such object. struct X refers to the type,...
  23. Replies
    9
    Views
    163

    You can find such examples in any good...

    You can find such examples in any good introductory C textbook.

    Nonetheless, here is an example:

    struct X
    {
    int a;
    float b;
    };
    Then using the notation you used in post #1:
  24. Replies
    9
    Views
    163

    A struct type is a type that can be used to group...

    A struct type is a type that can be used to group objects of various types together into a single object.
  25. It doesn't. Take a look at the GCC documentation...

    It doesn't. Take a look at the GCC documentation for Options for Linking. You will see this section:

    So, -lm would link to the library named m (or in context, libm), which should be contained in a...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4