I just started a new win32
console application in VS 2010 and set the Additional options
property to precompiled header
in the upcoming wizard.
Based on one of my previous questions I decided to use the following main prototype:
int main(int argc, char* argv[])
I also changed the Character Set
property of the project to Use Multi-Byte Character Set
.
But, the following code:
system("pause");
Will produce these two errors:
error C3861: 'system': identifier not found
IntelliSense: identifier "system" is undefined
I had the same experience before and there was no error!
Can anyone suggest me what's wrong?
In C++, you have to include the appropriate header file that contains the declaration of a function in order to use it, otherwise you'll get a compiler error about the identifier not being found.
In the case of the system
function, it is defined in the stdlib.h
header file.
So, to the top of your code file (or in your precompiled header file), add the line
#include <stdlib.h>
(You use the angle brackets instead of quotation marks because stdlib.h
is a header found in a place the build tool has been previously told about; this includes system header directories and other directories your build configuration specifically calls for.)
Aside from that, I strongly recommend against using either the Multi-Byte Character Set (all new Windows applications should support Unicode) or the system
function, especially system("pause")
.