How to access command-line arguments?
Answers were Sorted based on User's Feedback
Answer / hello
int main(int argc, char * argv[])
{
//argc has count of no of arguments on command line.
// argv[] contains array of strings seperated by space.
// so argv[1] will give u, second argument, with first
// argument being ur ./a.out(in unix)/test.exe(in win)
// so this way u can access CL args.
// ur code.
}
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / rakesh
int main(int argc,char *argv[])
{
int i;
for(i=0;i<argc;i++)
cout<<argv[i];
}
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / pb
argc is nothing but Argument Count
argv is nothing Argument Vector (or) Argument Value which
is array of Strings.
The first argument to the Command line is always the
Program Name.
argc contains no. of Arguments that it passed including the
Program Name.So Leave the 1st Argument,
int i;
for(i=1;i<=argc;i++)
cout<<argv[i];
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / padmaraj
By using -->
int main(int argc, char * argv[])
In this statement the variable argc holds the at least one
argument of type int , the name of the file it self first
argument and *argv[] is array of char which takes the name
of file.......
If any correction plz E-mail me ...
Bye
Is This Answer Correct ? | 0 Yes | 0 No |
why nlogn is the lower limit of any sort algorithm?
main() { int a[10]; printf("%d",*a+1-*a+3); }
main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10
main() { static int var = 5; printf("%d ",var--); if(var) main(); }
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h
Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector
Develop a routine to reflect an object about an arbitrarily selected plane
write a c-program to display the time using FOR loop
How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.
Write a routine that prints out a 2-D array in spiral order
Sir... please give some important coding questions asked by product companies..
There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.