Monday 27 August 2012

C command line program code using argv Example

c command line program code using argv
#include<stdio.h>
void main( int arge,char *argv[])
{
 FILE * fp;
 int i;
 char word[15];
 fp=fopen(argv[1],"w");
 printf("\nNo.of argument in command line=%d\n\n",arge);
 for(i=2;i<arge;i++)
 fprintf(fp,"%s",argv[i]);
 fclose(fp);
 printf("contents of %s file\n\n",argv[1]);
 fp=fopen(argv[1],"r");
 for(i=2;i<arge;i++);
{
 fscanf(fp,"%s",word);
 printf("%s",word);
 }
 fclose(fp);
 printf("\n\n");
 for(i=0;i<arge;i++)
 printf("%*s \n",i*5,argv[i]);
 }
Example for:-c command line program code using argv
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: