咸阳新闻,mp3 音乐,快乐女生nanana
一个简单的C++程序,Test函数用来测试调用Linux的系统命令ls -l
#include<cstdlib> #include<string> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int N = 300; void Test(void){ char line[N]; FILE *fp; string cmd = "ls -l"; // system call const char *sysCommand = cmd.data(); if ((fp = popen(sysCommand, "r")) == NULL) { cout << "error" << endl; return; } while (fgets(line, sizeof(line)-1, fp) != NULL){ cout << line << endl; } pclose(fp); } int main(){ Test(); return 0; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论