Author Topic: Command Line Arguments  (Read 6295 times)

Offline Kuriyaki

  • Single posting newcomer
  • *
  • Posts: 3
Command Line Arguments
« on: March 18, 2008, 06:10:59 am »
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!

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Command Line Arguments
« Reply #1 on: March 18, 2008, 10:10:41 am »
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.

Offline Kuriyaki

  • Single posting newcomer
  • *
  • Posts: 3
Re: Command Line Arguments
« Reply #2 on: March 18, 2008, 05:54:50 pm »
Awesome! Thank you very much. Was afraid people would consider it a coding/development question.

Offline Kuriyaki

  • Single posting newcomer
  • *
  • Posts: 3
Re: Command Line Arguments
« Reply #3 on: March 18, 2008, 06:08:31 pm »
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.