Reputation: 55
I have just started to learn C language and I'm just trying to write Hello World to get started but I get this error message. I'm sure the answer is obvious but can someone please tell me what I need to do? This is my code:
#include <stdio.h>
int main()
{
printf("Hello World ");
system("Pause");
return 0;
}
Upvotes: 2
Views: 19998
Reputation: 2496
You should include the following library.
#include <stdlib.h>
It's simple as that. I hope you find this useful.
Upvotes: 1
Reputation: 1114
As the others said, you need to include an header; if you're running on Linux, you may install "manpages-dev" package, and then tape "man system" which will tell you what are the headers you need to use.
Upvotes: 0
Reputation: 49393
You need to add another header file:
#include <stdlib.h>
When you have an undefined call like this you can always throw "man 3 system" and you'll get something like this so you can see if you're missing a header file.
FYI, for your specific program, you may want to consider no using system("Pause")
since it's system dependent. It would be better to pause with a break point (if you're using an IDE) or something more C standard like getchar()
Upvotes: 2
Reputation: 15814
Insert
#include <stdlib.h> //in C
or
#include <cstdlib> //in C++
before your main() function.
Note that your IDE should refrain from closing your program. If it doesn't, change IDE.
Upvotes: 1