Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 810
Monty123 Avatar asked Dec 07 '25 07:12

Monty123


2 Answers

printf(“Hello World”);

This should be written as -

printf("Hello World");

Straight quotes should be used. Try changing style .

like image 92
ameyCU Avatar answered Dec 08 '25 21:12

ameyCU


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 .

like image 45
Codo Avatar answered Dec 08 '25 19:12

Codo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!