command line argument in c
hii to all
i have a problem related to command line argument in c #include <stdio.h> main( int argc, char *argv[] ) { if( argc == 2 ) printf("The argument supplied is %s\n", argv[1]); else if( argc > 2 ) printf("Too many arguments supplied.\n"); else printf("One argument expected.\n"); } i have this code but i dont know how to execute this code in gcc plz be descriptive thanks |
You don't execute it in gcc, you compile it.
man gcc holds a host of information to explain how. Have a read, highly recommendable ;} Cheers, Tink |
first: gcc -o yourtext yourtext.c
second: ./yourtest parameter1 parameter2... last: you will get the answer you want |
i executed this code as
gcc code.c next for the output i type code 3 it says command not found when i try ./a.out 34 it is working my problem is why code 3 is not working |
man gcc
/-o Cheers, Tink |
okie thanks i got the point
|
Quote:
Quote:
Cheers, Tink |
All times are GMT -5. The time now is 04:16 PM. |