Showing posts with label Reading Data From Command Line. Show all posts
Showing posts with label Reading Data From Command Line. Show all posts

Saturday, 27 October 2012

Reading Data From Command Line

 Reading Data From Command Line


#include  <stdio.h>
 
#include <conio.h>
 
                                     int  argc;            /*   argument count */
                        
                                   char *argv[];        /* list of arguments */
 
   {
      
 FILE   *fp;
  
     int  i;
      
 char word[15];
     
       fp = fopen(argv[1], "w"); /* open file with name argv[1] */
   
    printf("\nNo. of arguments in Command line = %d\n\n",argc);
 
       for(i = 2; i < argc; i++)
    
          fprintf(fp,"%s ", argv[i]);      /* write to file argv[1]  */
       
fclose(fp);

 
    getch();
   }