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.
In this program we give the argument as command line.
Code:
#include"stdio.h"
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
Output:
bt@root#gcc cmdline.c -o cmdline
bt@root#./cmdline kushagra
hello kushagra
bt@root#gcc cmdline.c -o cmdline
bt@root#./cmdline kushagra
hello kushagra
No comments:
Post a Comment