Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.13 seconds; generated 53 minute(s) ago.

  1. Thread: Structs

    by laserlight
    Replies
    4
    Views
    35

    The Teir family has a few members. One of the...

    The Teir family has a few members. One of the members is named Brian. So, to differentiate him from a person named Brian from another family, or with no family name, we call him Brian Teir.

    Do you...
  2. Get rid of the spaces around the %i.

    Get rid of the spaces around the %i.
  3. You cannot use strcat because strcat itself...

    You cannot use strcat because strcat itself expects a null terminated string to concatenate to.

    Rather, as stahta01 implied, fread returns the number of items read, and since you're specifying...
  4. Replies
    1
    Views
    100

    In standard C, there is no such thing as a short...

    In standard C, there is no such thing as a short char, and there is no sign keyword (but perhaped you had signed in mind). A short int has a minimum range that mathematically requires at least 16...
  5. Replies
    5
    Views
    184

    Yeah, I'm of the opinion that compilers that...

    Yeah, I'm of the opinion that compilers that treat an empty identifier list in a function definition placed before another function definition as meaning "no information about the number or types of...
  6. Did you read the replies you were given? They...

    Did you read the replies you were given? They answer your question.

    If you're not interested in reading what people tell you about unions, then perhaps you shouldn't bother with unions. Change the...
  7. No, it doesn't. That else is a syntax error. If...

    No, it doesn't. That else is a syntax error. If you do want that else to match up with the very first if, you need to precede it by a closing brace so that the block associated with that if would end.
  8. I suggest breaking up your rather long function...

    I suggest breaking up your rather long function into smaller functions that each does one thing and does it well.

    Also, step through the code with a debugger. Where does the segfault occur? The...
  9. Replies
    5
    Views
    157

    No, it works for the entire array: struct s_rf...

    No, it works for the entire array:

    struct s_rf s_radioMssg = {{'F', '1', '2', '3', '4', '5', '6', '7', '8', '9'}, T};


    It doesn't: your array does not store a null terminated string.


    Use...
  10. Replies
    5
    Views
    157

    Is s_radioMssg really supposed to be a global...

    Is s_radioMssg really supposed to be a global variable, i.e., does it represent truly global state?

    If not, then I suggest that in your header:

    struct s_rf {
    char command[10];
    boolean...
  11. Replies
    5
    Views
    157

    The problem you're having is this: the member...

    The problem you're having is this: the member named command is an array, and you cannot assign to an array because it is not "a modifiable lvalue". You can assign to the elements of this array...
  12. Replies
    4
    Views
    255

    I suggest that you break down the problem into...

    I suggest that you break down the problem into parts, each of which corresponds to a function. For example:

    /* Returns the number of consonants in the string: */
    int count_consonants(const char...
  13. fopen returns a FILE*, not an int: the int is...

    fopen returns a FILE*, not an int: the int is because the result of fopen("foo","r") == NULL is an int. That warning message is exactly what Salem was talking about.
  14. Replies
    4
    Views
    448

    Is this supposed to be an array of string...

    Is this supposed to be an array of string constants? If so, then the best solution would be to define them inline in a header file:

    inline const char strings[][64] = {
    "One",
    "Two",
    ...
  15. What is your current code?

    What is your current code?
  16. Replies
    10
    Views
    184

    Yes, but you don't need the extern for function...

    Yes, but you don't need the extern for function declarations as they have external linkage by default.
  17. Replies
    10
    Views
    184

    It doesn't really matter where you put it in the...

    It doesn't really matter where you put it in the source file, so long as it is only one source file (so they are only defined once) and at file scope (so that they match the forward declarations).
  18. Replies
    10
    Views
    184

    The problem is that these are defined in the...

    The problem is that these are defined in the header:

    const unsigned int Customer_ID = 0xa316;
    const unsigned int CRC_Init = 0xFFFF;
    You would need to move them to a source file, replacing them...
  19. They are equally efficient and would probably...

    They are equally efficient and would probably compile to the same assembly code. In terms of style, I would recommend:

    void birthday(person *p) {
    p->age++;
    }
    Since birthday is defined...
  20. Replies
    7
    Views
    200

    In that case, I would suggest treating an array...

    In that case, I would suggest treating an array of char as a stack: whenever you encounter a character that is not a '#', push it into the stack. When you encounter a '#', pop from the stack if the...
  21. Replies
    7
    Views
    200

    Is your aim actually to replace each '#' with...

    Is your aim actually to replace each '#' with '\b', or is it to remove each '#' from the string?
  22. printf works with a format string. So you need to...

    printf works with a format string. So you need to specify a format string such as:

    printf("%d\n", fahrenheit_to_celsius(5));
    but note that your calculation uses integer arithmetic, which probably...
  23. Replies
    6
    Views
    214

    I think you need to rally your other students and...

    I think you need to rally your other students and collectively appeal for some kind of deadline extension until such time that classes have resumed so that you and your classmates can actually be...
  24. Replies
    5
    Views
    214

    How does it not work? For example, what is your...

    How does it not work? For example, what is your test input, expected output, and actual output? How did you arrive at the expected output from the test input (i.e., verify that you own calculations...
  25. By the way, did you really name the source file...

    By the way, did you really name the source file "IsMyFriendCheatingV5.C", as in with a ".C" (uppercase) rather than ".c" (lowercase) name suffix/extension? If so, you should be aware that some...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4