How to access command-line arguments?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

could you please send the program code for multiplying sparse matrix in c????

3281


How can you relate the function with the structure? Explain with an appropriate example.

3127


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2255


Design an implement of the inputs functions for event mode

3165


why nlogn is the lower limit of any sort algorithm?

2541






Sir... please give some important coding questions asked by product companies..

2022


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4074


how to test pierrot divisor

2461


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1296


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2501


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

2132


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2566


Write a program to model an exploding firecracker in the xy plane using a particle system

3867


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

2889


write a program for area of circumference of shapes

2229