我正在使用的文件如下所示:
#include <iostream>
#include <windows.h>
#include <stdio.h>
using namespace std;
int main()
{
char buffer[] = "file.txt\n";
FILE *fp = popen("input.exe", "w");
fwrite(buffer, sizeof(char), sizeof(buffer), fp);
pclose(fp);
}
调用已编译的程序
#include <iostream>
using namespace std;
int main()
{
string path;
cout << "Enter path ";
cin >> path;
cout << "You entered " << path << endl;
}
我从运行程序得到的输出是:
Enter path You entered file.txt
我正在使用popen重定向输入,但是如何也忽略cout << "Enter path";
?