Discussion :: Command Line Arguments - General Questions (Q.No.1)
|Rashmi said: (Jan 13, 2011)|
|Because command prompt depend on the Operating System (OS) and when OS change then the value of the command line argument changes.|
|Preetam Jadakar said: (Feb 17, 2011)|
|How to understand the which os offers which specification for cammand pompt?|
|Rajesh said: (Jul 1, 2011)|
|Command line arguments means?|
|Prathima said: (Sep 7, 2011)|
|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.
|Vijay said: (Sep 15, 2011)|
In DOS environment,maximum length is 128 characters.
& it vary according to os to os.
|Naresh said: (Dec 25, 2011)|
|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|
|Rathika.B said: (Jan 16, 2012)|
|Then what about the meaning of /*......*/ and //???
These also command-line arguments ah??
|Sidheshwar Kacharde said: (Feb 5, 2012)|
|It's right it's depend on OS.|
|Parvesh Kumar said: (Feb 6, 2012)|
|What is the use of command line argument and how can I use it ?|
|Kumarreddy said: (Mar 2, 2012)|
|Give brief discussion on command line arguments comparing with different os.|
|Shahaji Katale said: (Nov 21, 2012)|
|What is use of agrc agrv?|
|Sanjana said: (Jan 1, 2013)|
|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 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.
|Saran said: (Sep 24, 2013)|
|What is the use of command line argument?
Please can anyone say explanation for this?
|Sachin said: (Jan 20, 2014)|
|How is the working of Command line argument?|
|Haripadamaity said: (Oct 15, 2014)|
|Can you tell me the size in Linux?|
|Vrushali K said: (Sep 9, 2016)|
|What is the use of argc and argv?|
|Miclin Geo M J said: (May 1, 2017)|
|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())
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.
|Divya said: (Jun 16, 2017)|
|Friends, can anyone explain in linux?|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.