Hello, I am having an issue with the classic hello world program. I seem to have an issue when inserting the line "system("pause");" . Could someone direct me to what I am doing wrong?
/* Ewilkz
My Attempt at writing a program
8/23/14
oh hey, didn't see you there!!! */
These are the "errors" :
C:\Users\Eric\Desktop\Programming\My Programs\Hello World.cpp In function `int main()':
11 C:\Users\Eric\Desktop\Programming\My Programs\Hello World.cpp `system' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
Thanks for your comment. I found it, I guess? The file was saved as a C++ file and when I saved it as a .c file and compiled, I didn't come across any errors and it executed fine. Any reason/explanation/advice other than "just save your programs as a .c"?
Some compilers might deduce the language by the filename extension. A compiler in C-mode behaves differently from a compiler in C++-mode. That includes the implicitly linked libraries.
Suggestion: if you're not sure which #include is necessary, type the function name in the search box at the top of this page. That should lead you to the reference page where it will state which header is needed (and give sample code).