I want to build a CLI program with a command prompt in Linux, preferably using C++ (or maybe even Tcl). Where can I find resources? I need a good starting point, but whenever I search for answers I get other programs with their own CLI or prompts.
Something that I could also make work in DOS eventually would be great, but Linux is more important right now.
Where can I learn to build a CLI in Linux?
Not sure what exactly you're asking for. Are you experienced in C++ or Tcl? A C++ program with a command line interface is very easy to write. You just read input from stdin and write output to stdout. A very simplified example:
...
int input;
cout %26lt;%26lt; "Main Menu" %26lt;%26lt; endl %26lt;%26lt; "1) option 1" %26lt;%26lt; endl %26lt;%26lt; "2) option 2" %26lt;%26lt; endl %26lt;%26lt; "Choice? ";
cin %26gt;%26gt; input;
...
You can take command arguments at run time using the standard argv and argc notation. For example where foo is your program: "$foo -a 50" the command line arguments are "-a 50".
Suggested things to search for "c++ argv" for run time arguments and "c++ read input", "c++ I/O", etc etc for building a command line interface to your program. If this doesn't answer your question, perhaps you could clarify what you wish to accomplish?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment