Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

zahid@zahid-HP-Compaq-nc6400-EH522AV:~/programs$ 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?

share|improve this question
Did you copy this program from some other word processor or document like Libre office or Microsoft Word? – i08in Mar 26 '13 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. – Shubhangee Nath Jun 27 at 11:06

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;
share|improve this answer
+1 I was wondering how he got those back/forward quotes in there. – Aaron Mar 26 '13 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.) – Eliah Kagan Mar 26 '13 at 19:17

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.

share|improve this answer
problem program is compiled.tanx alot – Zahid Mar 26 '13 at 19:13
@Zahid In that case, if one of these answers helped, you should mark it as accepted by clicking the gray check mark to the left of it. If they both helped, you can accept either one. Accepting an answer shows not merely that the problem is solved but also that the accepted answer was considered helpful by the questions' author. (I'm not specifically trying to get you to accept my answer--in fact, since I've posted this as community wiki, I cannot gain any reputation from upvotes or acceptances. But unless neither of these answers helped, I'd encourage you to accept one or the other.) – Eliah Kagan Mar 26 '13 at 19:16

You can use the sed command to fix these issues.

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

sed s/[”“]/'"'/g File.txt

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

sed s/[”“]/'"'/g File.txt > WithoutSmartQuotes.txt

This will overwrite the original file.

sed -i ".bk" s/[”“]/'"'/g File.txt
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.