C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - General Questions (Q.No. 1)
1.
The maximum combined length of the command-line arguments including the spaces between adjacent arguments is
128 characters
256 characters
67 characters
It may vary from one operating system to another
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
18 comments Page 1 of 2.

Miclin Geo M J said:   8 years ago
Command line is nothing but the commands we give in a compiler to run the program finally for execution like ./a.out and so on.... Command line arguments is nothing but declaring the values in the command line which means that instead of providing values inside the code as int I; I am declaring after execution in the outer command line.

The argc will count the number of variables or the data you have input in the command line. *argv()(I do not have the other brace in my mobile please adjust) is to print or read the data you have provided on the command line.

Syntax to implement it in a program is as below,

Int main(int argc, char *argv())

Output:

If I am passing the values such as ./a.out 1 2 3 in the command line at the time of execution, the value if printed will be as;

Count(argc) will be 4. Command line ./a.out will be coming considered in as one count.
argv Will print all the values ./.a.out 1 2 3 to display.
(1)

Sanjana said:   1 decade ago
The full declaration of main looks like this:

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

The integer, argc is the argument count. It is the number of arguments passed into the program from the command line, including the name of the program.

The array of character pointers is the listing of all the arguments. argv[0] is the name of the program, or an empty string if the name is not available. After that, every element number less than argc is a command line argument. You can use each argv element just like a string, or use argv as a two dimensional array. argv[argc] is a null pointer.

Prathima said:   1 decade ago
main() function takes two arguments i.e main(int argc, char *argv[])

Here argc is the argument count and argv is a argument vector(argv is a array of pointers).

In DOS environment, maximum length is 128 characters. But the question is for all OS. So it may vary from OS to other OS.

Naresh said:   1 decade ago
It is possible to pass arguments to C programs when they are executed. The brackets which follow main are used for this purpose. argc refers to the number of arguments passed

Rashmi said:   1 decade ago
Because command prompt depend on the Operating System (OS) and when OS change then the value of the command line argument changes.

Vijay said:   1 decade ago
Its right
In DOS environment,maximum length is 128 characters.
& it vary according to os to os.

Rathika.b said:   1 decade ago
Then what about the meaning of /*......*/ and //???
These also command-line arguments ah??

Saran said:   1 decade ago
What is the use of command line argument?

Please can anyone say explanation for this?

Preetam jadakar said:   1 decade ago
How to understand the which os offers which specification for cammand pompt?

Kumarreddy said:   1 decade ago
Give brief discussion on command line arguments comparing with different os.


Post your comments here:

Your comments will be displayed after verification.