Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently installed 12.04 LTS and I would like to compile short c programs.

When I enter gcc or cc at the command promp to compile a simple test program "test.c"I get the following:

test.c: In function ‘main’:
test.c:6:1: error: stray ‘\342’ in program
test.c:6:1: error: stray ‘\200’ in program
test.c:6:1: error: stray ‘\234’ in program
test.c:6:1: error: stray ‘\342’ in program
test.c:6:1: error: stray ‘\200’ in program
test.c:6:1: error: stray ‘\235’ in program
test.c:6:11: error: ‘Test’ undeclared (first use in this function)
test.c:6:11: note: each undeclared identifier is reported only once for each function it appears in

Do I need to install other software (other than gcc?

sincerely,

Bruce

share|improve this question
add comment

2 Answers 2

That looks like a problem with your code. Not gcc, from what I can tell it's working properly.

Something like the wrong characters? Make sure you're using ' and not ´ etc.

share|improve this answer
add comment

You should look at line 6 of your code, and re-type it. It would solve the problem.

Here is an excerpt from http://www.giannistsakiris.com:

The errors were of this form:

 giannis@giannis-vbox:~$ gcc
program.c program.c: In function ‘main’: program.c:57: error: stray
‘\342’ in program program.c:57: error: stray ‘\200’ in program
program.c:57: error: stray ‘\234’ in program program.c:57: error:
stray ‘\’ in program 

I couldn't see any obvious syntactical error in the mentioned line. This is how line #57 looks like:

printf(“\nThe linked list representation is...\n”);

At first sight, it looks pretty fine, but if you look closely you will see that the double quotation marks that surround the string literal are not the neutral (vertical) ones (like this: "). They are left and right double quotation marks respectively.

If I replace the quotation marks with the neutral ones, like this:

printf("\nThe linked list representation is...\n");

the problem is solved. So, if you are getting this kind of error maybe you should look closely to any double (or single) quotation marks in the erroneous line.

share|improve this answer
add comment

Your Answer

 
discard

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.