Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code::blocks, define default input

I want to execute in Code::blocks IDE program providing standard input.

Say

                                                                                              #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;
}

With arguments "a" and "b" , provided in file:

Say:

2 4

I could do that in bash, compiling and then:

"./my_compiled_program < ./myinput"

I simply want to have, file with argument (standard input) in code::blocks.

How can I do this? PS: The "set program's arguments" unfortunately don't worksSet program's argument

like image 491
Paul Brewczynski Avatar asked Jun 22 '26 01:06

Paul Brewczynski


1 Answers

Thanks to @aleguna:

We should make file in folder where is the file we want to compile and execute: Place input next to source code

And then add the < ./input to program arguments, where input is the name of file we placed next to source code.

In code::blocks

Thank you @aleguna.

like image 90
Paul Brewczynski Avatar answered Jun 23 '26 14:06

Paul Brewczynski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!