我想在Code::blocks IDE程序中执行提供标准输入。
说
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a;
double b;
cout << "Side one\n";
cin >> a;
cout << "Side two\n";
cin >> b;
cout << "Result :" << sqrt(a*a + b*b) << endl;
}带有参数"a“和"b”,在file中提供:
可以这样说:
2 4我可以在bash中做到这一点,编译然后:
"./my_compiled_program < ./myinput"我只想在code::块中有带参数(标准输入)的文件。
我该怎么做呢?PS:不幸的是,“设置程序的参数”不起作用

发布于 2012-11-02 22:47:53
感谢@aleguna.
我们应该在文件夹中创建文件,其中是我们想要编译和执行的文件:

然后将< ./input添加到程序参数中,其中input是我们放在源代码旁边的文件的名称。

谢谢你@aleguna.
https://stackoverflow.com/questions/13196915
复制相似问题