Home > database >  missing terminating ' character (C, version 13, Xcode Terminal)
missing terminating ' character (C, version 13, Xcode Terminal)

Time:12-03

I'm just getting into C and this is the code I'm trying to get the compiler to run using gcc:

#include <stdio.h>

main()

{

printf("hello, world\n");

}

Every time I type gcc helloworld.c (helloworld.c is the name of the source file), the following error message appears:

helloworld.c:1:1: error: expected identifier or '('
{\rtf1\ansi\ansicpg1252\cocoartf2580
^
helloworld.c:13:9: warning: missing terminating ' character [-Winvalid-pp-token]
printf(\'93hello, \'93);\
        ^
1 warning and 1 error generated.

I tried switching to single quotation and putting quotation marks around every single character but nothing worked. Does anyone have any ideas what's wrong with the syntax?

CodePudding user response:

Try writing the program out by hand. If you copy-pasted it from somewhere, you might have put some weird invisible characters and formatting stuff. I copy-pasted the code from your example and it worked just fine. Compiled successfully with GCC:

gcc input.c -o program

  • Related