Thread: freading from multiple opened files

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    67

    freading from multiple opened files

    hi, ive got this piece of code:
    Code:
    #include <stdlib.h>
    #include <stdio.h>
    
    int main()
    {
        int ping, bestandopen;
        FILE *bestand;
        char command[20], bestandje[20];
        char buffer[256];
        
        /* ping de hosts, sla de resultaten op een de file.
         * per Ip word er een file gemaakt.
         * */
        
        for (ping = 0; ping <= 10; ping++) // loop van 1 tot ... (argv?)
        {
            sprintf(command, "ping -n 1 10.10.100.%d > outfile%d.txt", ping, ping);
            system(command);        
        }
        
        /*
         * bestandjes worden hier geopend
         **/
        
        for (bestandopen = 0; bestandopen <= 10; bestandopen++)
        {
            sprintf(bestandje, "outfile%d.txt", bestandopen);
            fopen("bestandje", "r");
            
            memset(buffer, 0x00, sizeof(buffer));
            
            while (fgets(buffer, sizeof(buffer) - 1, bestand) != NULL) 
            { 
                 
                 if (strstr(buffer, "Reply")) 
                 {
                      
                      fprintf(stderr, "blalal ping timeout..\n"); 
                      fclose(bestand); 
                 }                   
            }
                            
            
            
            printf("FILE_OPENED: %s\n", bestandje);
        }
              
        return 0;
    }
    it opens the files, and I know how to read from a single file using fgets, but how can i loop through the all the files and filter out a word (Reply in this case).
    thanx
    Last edited by TeQno; 05-23-2003 at 06:34 AM.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    67
    never mind i fixed it (thanks to SEARCH )
    next time ill search better before i open my big mouth
    Last edited by TeQno; 05-23-2003 at 08:42 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 02-25-2008, 06:35 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Opening Multiple Files in sequence
    By wujiajun in forum C++ Programming
    Replies: 7
    Last Post: 01-16-2006, 08:47 PM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. copy multiple files to a destination file
    By Bones in forum C++ Programming
    Replies: 2
    Last Post: 10-02-2003, 10:47 AM