使用Linux编写helloworld程序报错如下:
#include <iostream>
using std::cout;
using std::endl;
int main(){
cout << "hello world" << endl;
return 0;
}
$ g++ hello.cpp
hello.cpp: In function ‘int main()’:
hello.cpp:7:16: error: ‘system’ was not declared in this scope
system("pause");
解决办法
包含头文件
#include <cstdlib>