answersLogoWhite

0


Best Answer

The command line is represented in C or C++ as a call to main with two arguments...

int main (int argc, char* argv[]);

The argc variable is the number of arguments, and is always at least 1, because the first argument, argv[0], is the program name itself.

Each word in the command line is then presented in successive argv[n] variables. For instance, if you type thiscommand one two three, argc will be 4, and argv[n], n being 0 through 3, will be "thiscommand", "one", "two", and "three", without the quotation marks, of course.

Some implementations provide other functionality, such as an additional char *envp[] argument which contains the environment, but that is not ANSI. In the MS Windows environment, the entry point is to winmain for windows programs, and to main for console programs.

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);

In this case, the full command line is in lpCmdLine.

Other operating systems may have alternate entry points, but I do not know them as well as MS Windows. Other contributors - please refine this answer if appropriate.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Command line argument in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you get to the g plus plus compiler once it is installed on ubuntu?

The C++ compiler is invoked with g++, however on many systems it is installed as c++. Consult the documentation for information on the command line options.


Can comments be longer than one line and if yes how?

C++ also supports C program's multiple command line /* your command */.


What is the c plus plus command to read a line?

You can use cin which located in iostream.h You have to use certain data type to read string, for instance, array of char


What is the s switch in formats?

When using the format command in DOS, the /s command-line argument "format c: /s" tells the system to copy over the system files necessary to make the drive DOS bootable. It is the same as using the "sys" command after finishing the format.


What is null printer in c plus plus?

There is no such thing as a null printer in C++. You are perhaps thinking of the null device to which output can be redirected from the command line (effectively hiding the output of a program). However this has nothing whatsoever to do with C++, it is entirely dependant upon the operating system.


Please someone explain you command line argument in C?

Command Line Arguments---- I am trying to explain each word one by oneCommand ------perform specific taskex. When CMD is typed in run window and then press ok button then open a black screen that is called command prompt.Command Line ------on command prompt where command is supplied that is called command line.using command prompt dos commands are executed and java program is also executed using command prompt.for executing java program command is supplied with given syntaxjava java_class_name argument1 argument2.........Java--- is a commandjava_class_name ---name of java file which you want to executeargument1 argument2 --- are the values passing to java application from out sidethese argument1 argument2 are stored in string array argument of main method


Why c plus plus language is called command oriented language?

C++ is not a command oriented language, it is a multi-paradigm language because it employs functional and object-oriented approaches to programming.


How can you view page by page output in c plus plus?

Pipe the output to the MORE command.


How do you pass command line arguments using turbo in c compiler?

In the Options menu the Arguments command.


What is argument in c plus plus?

If this is a homework assignment, please consider trying to answer it yourself first, otherwise the value of the reinforcement of the lesson offered by the assignment will be lost on you.An argument (or parameter) in C or C++ is a special variable that is passed to a function when it is called. In the example...float sin(float x);... the x is an argument. Within the body of the function, x refers to the copy of the caller's argument that was passed to the function.


How does xcode 3.2 work with c plus plus?

XCode is really nothing more than a GUI front-end for a wide-variety of coding tools. Both C and C++ are built-in to the Mac operating system so you can use the cc command line tool to compile both C and C++, however most users prefer a GUI to the command line, thus gaining the advantage of a more integrated development environment (IDE). XCode integrates with gcc, which is better suited to cross-platform development than the built-in cc compiler.


What command is the control key plus c?

Copy the selected text (or object).