c语言中的popen函数存在一个潜在的问题
发布时间
阅读量:
阅读量
执行了两次popen指令,然而所获取的输出结果却保持一致
#include<stdio.h>
#include<string>
#include<cstdlib>
#include<iostream>
using namespace std;
int main()
{
FILE *fp = NULL;
char name[100] = {'0'};
fp = popen("whoami", "r");
if (fp == NULL)
{
printf("popen error!\n");
return 1;
}
while (fgets(name, sizeof(name), fp) != NULL);
pclose(fp);
fflush(stdin);
fflush(stdout);
string operate = "mkdir ";
string operName = name;
operate = operate + operName;
system((char*)operate.c_str());
char filename[100]
全部评论 (0)
还没有任何评论哟~
