Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.14 seconds.

  1. Replies
    4
    Views
    110

    "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...
  2. Replies
    4
    Views
    110

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

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

    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...
  4. Replies
    2
    Views
    61

    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();
  5. Replies
    5
    Views
    180

    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,...
  6. Replies
    42
    Views
    610

    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...
  7. Replies
    42
    Views
    610

    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...
  8. * moved to Tech Board *

    * moved to Tech Board *
  9. 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...
  10. 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...
  11. 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...
  12. 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,...
  13. 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:
  14. 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.
  15. 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...
  16. Replies
    3
    Views
    143

    What happens is that the standard input stream...

    What happens is that the standard input stream enters a failed state. You need to clear the state and remove the bad input.

    Instead of this, another option when dealing with such line-based input...
  17. Yes. In general, a pointer to some type X cannot...

    Yes. In general, a pointer to some type X cannot store values of type X. It can only store addresses of objects of type X (or be a null pointer), so if you want to store a value of type X using such...
  18. You forgot to set the pointer to point to an...

    You forgot to set the pointer to point to an object, so what happens is that the pointer to garbage (or which happens to be a null pointer by chance) is dereferenced, possibly leading to a...
  19. Replies
    5
    Views
    131

    That's because you're trying to treat dict[j] as...

    That's because you're trying to treat dict[j] as a pointer when it is an object. Write dict[j].name instead.


    C only has pass by value semantics. Pass by reference can still be done through a...
  20. Replies
    5
    Views
    131

    You have an array of DICTIONARY objects, so when...

    You have an array of DICTIONARY objects, so when you pass it as an argument, it is converted to a pointer to its first element. Hence, you should declare your function like this:

    uint32_t...
  21. Replies
    10
    Views
    132

    Yes, but you should still be aware that it is not...

    Yes, but you should still be aware that it is not the array itself that is passed, but rather the array is converted to a pointer to its first element, hence for that function call, the parameter...
  22. Replies
    11
    Views
    292

    I would have thought it more likely to report...

    I would have thought it more likely to report that theta wasn't declared.
  23. Replies
    18
    Views
    218

    That's not a problem; it's a technical...

    That's not a problem; it's a technical description of when and how one or more tentative definitions in a translation unit are coalesced into a single definition.


    The program has two translation...
  24. Replies
    18
    Views
    218

    Notice that tentative definitions are coalesced...

    Notice that tentative definitions are coalesced into a single definition per translation unit, not across the entire program.
  25. Replies
    18
    Views
    218

    A "shall" clause is a requirement on a program,...

    A "shall" clause is a requirement on a program, the violation of which results in undefined behaviour. A conforming compiler must accept conforming programs, but isn't required to accept...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4