Monday, 7 October 2013

How to implement Variable arguments in c

Before you start: To learn how to compile a c program in C click here or click here

Variable Arguments or say command line arguments are an important as well as basic and necessary concept in real world software point of view.
In this program we give the argument as command line.



main( char argc,char *argv[])
printf("\nhello %s \n",argv[1]);

It's a simple program which takes command line arguments. Let save it as cmdline.c
bt@root#gcc cmdline.c -o cmdline
bt@root#./cmdline kushagra
hello kushagra

To learn more in C click here

No comments:

Post a Comment