COMMAND LINE ARGUMENTS

/*  COMMAND LINE ARGUMENTS  */

#include<stdio.h>
void main(int argc,char *argv[])
 {
  FILE *f1;
  char c;
  if(argc>2)
  printf("Insufficient argument");
  f1=fopen(argv[1],"r");
  printf("The content of given input file is as
                                      follows\n");
  while((c=getc(f1))!=EOF)
     printf("%c",c);
  fclose(f1);
 }

OUTPUT:
-------
C:\Documents and Settings\sss>cd..
C:\Documents and Settings>cd..
C:\>cd turboc3
C:\TURBOC3>comline comline.c
  The content of given input file is as follows
  #include<stdio.h>
  void main(int argc,char *argv[])
    {
     FILE *f1;
     char c;
     if(argc>2)
     printf("Insufficient argument");
     f1=fopen(argv[1],"r");
     printf("The content of given input file is as  
                                         follows\n");
     while((c=getc(f1))!=EOF)
        printf("%c",c);
     fclose(f1);
    }



No comments:

Related Posts with Thumbnails