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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: