從system返回值中獲得程序退出碼

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;
int main(int argc, char* argv[])
{
	cout << "test1" << endl;
	string cmd = "./test2";
	int status = system(cmd.c_str());
	cout << WEXITSTATUS(status) << endl;
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章