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
1
  • 1
    please edit your question and include the source code, the command you are using to compile and the text of the error message. Apr 11, 2016 at 9:51

1 Answer 1

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
2
  • I didn't realize that main() could be untyped...
    – Jacobm001
    Apr 11, 2016 at 15:30
  • @Jacobm001 It is not supposed to be but it does compile. Apr 11, 2016 at 15:36

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