Write a C program to read arguments at the command line and display it.
Algorithm:
1. Start
2. Pass a to arguments argc and argv in the main function
3. Check the condition argc equal to 2 then printf the argv[1] value
4. else if argc is greater than 2 the print Too many arguments supplied
5. else One argument expected
6. Stop
Program Code:
#include<stdio.h>
#include<string.h>
void main(int argc,char *argv[])
{
int i; printf("\n total no of arguments=%d",argc);
for(i=0;i<argc;i++)
printf("\n args[%d]=%s",i,argv[i]);
}
Thanks
Mukesh Rajput
Post A Comment:
0 comments: