Search code examples
cgccencodingcharacter-encoding

Compilation fails due to strange characters appearing in source code


I'm trying to write a simply Hello, World! program, but when attempting to compile with GCC, I receive the following error:

helloworld.c:5:18: error: expected ‘)’ before ‘World’
  printf(“Hello World”);
                  ^
helloworld.c:5:18: error: stray ‘\342’ in program
helloworld.c:5:18: error: stray ‘\200’ in program
helloworld.c:5:18: error: stray ‘\235’ in program

Why is this?

Compiler: GCC 4.8.4 (2014-12-19). OS: Ubuntu 14.04 (Trusty Tahr).


Solution

  • The octal sequence 342 200 234 is the UTF-8 byte sequence for the typographic double quote.

    To fix it, replace it with the regular double quote, i.e. " instead of .