0

I wrote a program using nano and tried to compile it using gcc command on Lx-terminal. It's showing stray error. Can anyone tell me what is the problem? For simple "hello world" program also is showing errors.

Code:

#include<stdio.h>
main()
{
printf(hello world;
}

Output:

ello.c:49:14: error: stray \253 in program
hello.c:49:14: error: stray \217 in program
hello.c:49:14: error: stray \33 in program
hello.c:49:14: error: stray \1 in program
hello.c:49:939: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:943: warning: null character(s) ignored
hello.c:49:14: error: stray \25 in program
hello.c:49:946: warning: null character(s) ignored
hello.c:49:14: error: stray \5 in program
hello.c:49:14: error: stray \6 in program
hello.c:49:988: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:993: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:995: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:998: warning: null character(s) ignored
hello.c:49:1002: warning: null character(s) ignored
ello.c:49:14: error: stray ‘\253’ in program
hello.c:49:14: error: stray ‘\217’ in program
hello.c:49:14: error: stray ‘\33’ in program
hello.c:49:14: error: stray ‘\1’ in program
hello.c:49:939: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\4’ in program
hello.c:49:943: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\25’ in program
hello.c:49:946: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\5’ in program
hello.c:49:14: error: stray ‘\6’ in program
hello.c:49:988: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\21’ in program
hello.c:49:993: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\21’ in program
hello.c:49:995: warning: null character(s) ignored
hello.c:49:14: error: stray ‘\4’ in program
hello.c:49:998: warning: null character(s) ignored
hello.c:49:1002: warning: null character(s) ignored
ello.c:49:14: error: stray \253 in program
hello.c:49:14: error: stray \217 in program
hello.c:49:14: error: stray \33 in program
hello.c:49:14: error: stray \1 in program
hello.c:49:939: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:943: warning: null character(s) ignored
hello.c:49:14: error: stray \25 in program
hello.c:49:946: warning: null character(s) ignored
hello.c:49:14: error: stray \5 in program
hello.c:49:14: error: stray \6 in program
hello.c:49:988: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:993: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:995: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:998: warning: null character(s) ignored
hello.c:49:1002: warning: null character(s) ignored
ello.c:49:14: error: stray \253 in program
hello.c:49:14: error: stray \217 in program
hello.c:49:14: error: stray \33 in program
hello.c:49:14: error: stray \1 in program
hello.c:49:939: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:943: warning: null character(s) ignored
hello.c:49:14: error: stray \25 in program
hello.c:49:946: warning: null character(s) ignored
hello.c:49:14: error: stray \5 in program
hello.c:49:14: error: stray \6 in program
hello.c:49:988: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:993: warning: null character(s) ignored
hello.c:49:14: error: stray \21 in program
hello.c:49:995: warning: null character(s) ignored
hello.c:49:14: error: stray \4 in program
hello.c:49:998: warning: null character(s) ignored
hello.c:49:1002: warning: null character(s) ignored

closed as off-topic by Jacobm001, Steve Robillard Apr 11 '16 at 15:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Jacobm001, Steve Robillard
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    please edit your question and include the source code, the command you are using to compile and the text of the error message. – Steve Robillard Apr 11 '16 at 9:51
2

The problem is with your printf line.

printf(hello world;

you are missing the closing parenthesis ")", You are also missing quotes around the text "Hello World"

change that line to:

printf("hello world");

Your final code should look like this

#include<stdio.h>
main()
{
  printf("hello world");
}

You can then compile it with this command:

gcc -o helloworld helloworld.c

You should now have an executable called helloworld that can be run by typing:

./helloworld
  • I didn't realize that main() could be untyped... – Jacobm001 Apr 11 '16 at 15:30
  • @Jacobm001 It is not supposed to be but it does compile. – Steve Robillard Apr 11 '16 at 15:36

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