-1

Here's the error I get:

genlib.h:225:1: error: stray ‘\32’ in program

genlib.h is defined in: http://pastebin.com/KgM3J24W

Here's my code:

/*
 * file: hello.c
 * -----------
 *  This program prints the message "Hello World."
 *  On the screen. The program is taken from the 
 *  classic C reference text "The C Programing
 *  Language" by Brian Kemighan and Dennis Richie.
 */

#include <stdio.h>
#include "genlib.h"

int main()
{
    printf("Hello, World.\n");
    return 0;
}
  • You have an invisible character (`032` octal) on line 225. Check your file (with a hex editor, another text editor, etc.) Also, I do not understand why you need some random header (`"genlib.h"`) for compiling a trivial Hello World. – The Paramagnetic Croissant Apr 12 '14 at 05:15
  • 1
    http://stackoverflow.com/questions/7663565/error-stray-xxx-in-program-why – scarecrow Apr 12 '14 at 05:15
  • @user3477950 answering your question of why I need to use (`"genlib.h"`). The reason I need to use is because my professor is teaching us C with this library. – Titty Slap Apr 12 '14 at 05:27
  • @TittySlap but you still don't need it for a hello world. Maybe the problem is in his header file. Try removing it and re-compiling. (Also, in the meantime, did you check that line using a hex editor?) – The Paramagnetic Croissant Apr 12 '14 at 05:28
  • @user3477950 I have very minimal programing experience, and i don't understand how to use hex editors. I don't think I am supposed to use that in the first place, since I am only taking introduction to C programing. – Titty Slap Apr 12 '14 at 05:35

1 Answers1

0

Open the file genlib.h, go to the very last line where there is a garbage character (as can be seen in your linked page http://pastebin.com/KgM3J24W), remove that character, and then save the file again.

If your editor doesn't show the garbage character, perhaps you can try to create a new, empty file called genlib2.h, copy the content from genlib.h (without the garbage), save genlib2.h, and then rename genlib2.h to genlib.h.

The invisible character (032 octal) can also be written as ^Z, and was used in MS-DOS and old Windows to mean end-of-file. Someone probably added it by mistake when entering the content of genlib.h.

Thomas Padron-McCarthy
  • 27,232
  • 8
  • 51
  • 75