News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Command Line Arguments

Started by Kuriyaki, March 18, 2008, 06:10:59 AM

Previous topic - Next topic

Kuriyaki

Is it possible to use command line arguments? In other words...

int main( int argc, char* argv[] )
{
    ... // Program that uses the input from user in terminal window? argv[1], 2...etc
   
    return 0;
}

I'm fairly new with CodeBlocks. Sorry for the question. Looks great so far!

Ceniza

Yeah, sure. Just add them thru Project -> Set program's arguments... Select the target you want, add its arguments and click OK. Now, when you click on Run, Code::Blocks will pass those arguments to your executable.

Before you ask: it only works for projects.

Kuriyaki

Awesome! Thank you very much. Was afraid people would consider it a coding/development question.

Kuriyaki

Whenever I want to read/write to a file in CodeBlocks

Where should I place those files? Under the main project folder? Is it able to write to files? Been trying to and it doesn't allow me.