Frequently Seen Mistakes

  1. You get the correct results in grace, but not in the submit server - This may happen because:
    • You have uninitialized variables. Grace seems to set uninitialized variables to 0.
    • Your strings are missing a null character ('\0').
    • You are not declaring an array that is large enough.
    • When iterating over an array the code is going beyond the array memory area (e.g., off by one).
    • You are passing to a function a pointer to a character rather than a pointer to an array of characters.
  2. Your code might be generating a core dump in the submit server if, for a test, the submit server displays a message along the lines:

    "expected ... but output ended".

  3. If you are missing a required function or has a typo in a function (e.g., prontf instead of printf) you may get a message similar to the following:

    "collect2: error: ld returned 1 exit status"

  4. If your code is not compiling in the submit server it might be due to a function that is not implemented. Provide an empty body (with a dummy return value if needed) for functions you have not implemented yet so your code compiles in the submit server.
  5. You are returning a pointer to a local variable.
  6. Check your pointer variables are initialized correctly.
  7. You see the error "ISO C90 forbids mixed declarations and code [-Wpedantic]". The gcc alias for this class requires variables to be declared at the top of a block. The following code will generate the above error:
    		   int main() {
                          int x;
                          return 0;
    To correct the error, make int x; the first statement in the block.
  8. If you get an error along the lines of "stack smashing" the problem could be you are writing to an area you not supposed to access (e.g., array out of bounds access).
  9. Using sizeof() incorrectly. For example, using sizeof() to determine the size of an array parameter. In this case sizeof() will return the number of bytes associated with a pointer type, not the number of elements in the array.
  10. Debugging information can be found at Debugging in C.
Web Accessibility