I wrote this program:

int main()
printf(“Hello World\n”);
return 0;

I saved it as first.c and tried to compile but receiving this problem I have installed even gcc compiler too.

$ gcc first.c -o first1
first.c: In function ‘main’:
first.c:4:1: error: stray ‘\342’ in program
first.c:4:1: error: stray ‘\200’ in program
first.c:4:1: error: stray ‘\234’ in program
first.c:4:11: error: ‘Hello’ undeclared (first use in this function)
first.c:4:11: note: each undeclared identifier is reported only once for each function 
it appears in
first.c:4:17: error: expected ‘)’ before ‘World’
first.c:4:17: error: stray ‘\’ in program
first.c:4:17: error: stray ‘\342’ in program
first.c:4:17: error: stray ‘\200’ in program
first.c:4:17: error: stray ‘\235’ in program

How can I fix this problem?

  • Did you copy this program from some other word processor or document like Libre office or Microsoft Word?
    – jobin
    Mar 26, 2013 at 18:02
  • if you have copied the code from somewhere then rewrite the code on your own as the code that you have copied may have some unwanted codes embedded in it.
    – user561837
    Jun 27, 2016 at 11:06

3 Answers 3


The problem is that you have Unicode quotation marks instead of ASCII quotation marks; probably your editor automatically changed them, or you copied the text from a site that does this automatically in its authoring software. Replace the quotes with normal ASCII quote (0x22, ") and it should work.

Fixed source:

#include <stdio.h>
int main()
    printf("Hello World\n");
    return 0;
  • +1 I was wondering how he got those back/forward quotes in there.
    – Aaron
    Mar 26, 2013 at 18:04
  • Unicode vs. ASCII quotation marks might not be the best way to state the distinction, since the correct quotation marks for strings in C (") are Unicode characters, too. (They also happen to be ASCII characters but anytime someone is choosing between the two, their file is probably saved in some Unicode format. On a Unix-like system, usually UTF-8.) Mar 26, 2013 at 19:17
  • other sneaky characters are the instead of the -. Apr 19, 2018 at 15:26

You're enclosing your string in the wrong kind of quotes.

You have:

“Hello World\n”

You should instead have:

"Hello World\n"

While the quotes you've used look similar, they are not recognized by a C compiler as enclosing a string. Thus, you get error messages about unrecognized Unicode characters, and you get error messages showing that the contents of the string are being interpreted as unquoted program code.

You will note that the quotes you've used have separate characters for beginning and ending a quotation (they are curved the way quotes are often typeset). Many word processors--as Jobin suggested--will automatically turn simple " quotes into such fancy quotation marks. If you're using a word processor to compose C programs, you should use a text editor instead.

Ubuntu comes with gedit installed by default (though there are many other text editors to choose from, too). Like many text editors, gedit provides syntax highlighting for many programming languages including C (so different text in your program will shown in different colors to signify its meaning), which is a handy feature and makes a text editor much more convenient and user-friendly for programming than a word processor.

This might be Ubuntu-specific, if you're used to a text editor on another platform that automatically reduces pasted quotations marks to the non-fancy version. But this question might end up getting closed and migrated to Stack Overflow.

  • problem solved.my program is compiled.tanx alot
    – Zahid
    Mar 26, 2013 at 19:13

You can use the sed command to fix these issues.

This will give you a quick preview of what will be replaced.

sed -re 's/”|“/"/g' File.txt

This will do the replacements and put the replacement in a new file called WithoutSmartQuotes.txt:

sed -re 's/”|“/"/g' File.txt > WithoutSmartQuotes.txt

This will overwrite the original file:

sed -i .bk -re 's/”|“/"/g' File.txt

Not the answer you're looking for? Browse other questions tagged .