linux c 获取console 结果时间:2023-03-09 18:18:41 getLine(char *line, const char *cmd) { FILE *pf = popen(cmd, "r"); if (pf == NULL) { return -; } fgets(line, , pf); if (strlen(line) > ) { if (line[strlen(line) - ] == '\n') line[strlen(line) - ] = '\0'; } pclose(pf); return ; }