linux µÃµ½ÏµÍ³Ê±¼ä
ÿÌì×ܽáÒ»µãµã£¬³É³¤Ò»µãµã~~
1.Í·Îļþ
#include <ctime>
void executeCMD(const char *cmd, char *result){ char buf_ps[1024]; char ps[1024]={0}; FILE *ptr; strcpy(ps, cmd); if((ptr=popen(ps, "r"))!=NULL) { while(fgets(buf_ps, 1024, ptr)!=NULL) { strcat(result, buf_ps); if(strlen(result)>1024) break; } pclose(ptr); ptr = NULL; } else { printf("popen %s error\n", ps); }}