2 Replies - 273 Views - Last Post: 02 September 2011 - 12:01 AM Rate Topic: -----

#1 machoolah  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 87
  • Joined: 17-May 09

create a console application that gets keys/switches as parameter

Posted 01 September 2011 - 08:59 PM

Hi,
I'd like to know what's the best practice to create console applications that can accept switches (or keys - I am not sure about the terminology) when called. As an example, consider a simple hello world application that has 3 different outputs:
1. HELLO WORLD
2. hello world
3. Hello World

I want the output be HELLO WORLD if I run helloworld.exe -u, hello world if I run helloworld.exe -l and Hello World if I run helloworld.exe -c.

As an extension, I want to be able to use 2 or more switches/keys, when calling my application. (This might be easy once the first problem is solved!)

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: create a console application that gets keys/switches as parameter

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 3846
  • View blog
  • Posts: 11,771
  • Joined: 25-December 09

Re: create a console application that gets keys/switches as parameter

Posted 01 September 2011 - 09:09 PM

You may want to look at these links: Command line arguments, and command line arguments 2.


Jim
Was This Post Helpful? 1
  • +
  • -

#3 hulla  Icon User is offline

  • sqrt(-1) am awesome


Reputation: 49
  • View blog
  • Posts: 727
  • Joined: 05-March 11

Re: create a console application that gets keys/switches as parameter

Posted 02 September 2011 - 12:01 AM

I think they're called flags if I'm not wrong.

Or Parameters.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1