user1984103
user1984103

Reputation: 55

error: identifier "sytem" is undefined

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

Answers (6)

miksiii
miksiii

Reputation: 2496

You should include the following library.

 #include <stdlib.h>

It's simple as that. I hope you find this useful.

Upvotes: 1

bagage
bagage

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

Mike
Mike

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

Raghu Srikanth Reddy
Raghu Srikanth Reddy

Reputation: 2711

#include<stdlib.h>

Include this header file..

Upvotes: 3

milleniumbug
milleniumbug

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

simonc
simonc

Reputation: 42165

You need to #include <stdlib.h>

If you aren't sure which header a standard function is defined in, its man page will tell you.

Upvotes: 1

Related Questions