Running programs in a batch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhankrish
    New Member
    • Dec 2006
    • 16

    Running programs in a batch

    hello all,
    i have around 200 .csv files.
    i have written a code which opens one file, sorts the data in the file and gives the required output.
    i have to do this for all the 200 files.
    should i change the file name in the fopen statement everytime and run the program 200 times?
    or is it possible to analyse all the files at a time (in a batch)
    any help will be highly appreciated

    thanks
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by madhankrish
    hello all,
    i have around 200 .csv files.
    i have written a code which opens one file, sorts the data in the file and gives the required output.
    i have to do this for all the 200 files.
    should i change the file name in the fopen statement everytime and run the program 200 times?
    or is it possible to analyse all the files at a time (in a batch)
    any help will be highly appreciated

    thanks
    if your filenames have some consistent nameing system you could have a loop which creates the filename then opens and processes it. e.g. assuming your files were called file1, file2, file3, etc
    Code:
    #include <stdio.h>
    
    int main()
    {
        int i;
        for (i=1;i<=20; i++)
          {
           char filename[20]="file", number[10];
           sprintf(number,"%d", i);    // convert number to characters
           strcat(filename, number);   // append on end of filename
           printf("filename %s\n", filename);
           // ** open file and process it
           }
          getchar();       
    }
    prints
    filename file1
    filename file2
    filename file3
    filename file4
    filename file5
    filename file6
    filename file7
    filename file8
    filename file9
    filename file10
    filename file11
    filename file12
    filename file13
    filename file14
    filename file15
    filename file16
    filename file17
    filename file18
    filename file19
    filename file20

    Comment

    • madhankrish
      New Member
      • Dec 2006
      • 16

      #3
      thankyou
      i will try it out

      madhankrish

      Comment

      Working...