error C3861: 'system': identifier not found
Solution 1
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")
.
Solution 2
What worked for me was ensuring that the #include "stdafx.h"
was the FIRST INCLUDE in the file. So #include <iostream>
would therefore be after this.
Doing this solved the issue.
Sepideh Abadpour
Updated on October 21, 2020Comments
-
Sepideh Abadpour over 3 years
I just started a new
win32
console application in VS 2010 and set theAdditional options
property toprecompiled 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 toUse 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?