我写了下面这个简单的C++程序,目的是学习如何从C++程序中调用Linux命令(使用system命令)
请指导为什么我会从C++编译器得到错误?我的程序有什么问题?
更多exm2.cc
#include <stdio.h>
#include <stdlib.h>
int main()
{
system("echo -n '1. Current Directory is '; pwd");
system("mkdir temp");
system();
system();
system("echo -n '3. Current Directory is '; pwd");
return 0;
}
[root@linux /tmp]# g++ -Wall exm2.cc -o exm2.end
/usr/include/stdlib.h: In function גint main()ג:
/usr/include/stdlib.h:738: error: too few arguments to function גint system(conג
exm2.cc:7: error: at this point in file
/usr/include/stdlib.h:738: error: too few arguments to function גint system(conג
exm2.cc:8: error: at this point in file