reading multiple files in C

This is a discussion on reading multiple files in C within the C Programming forums, part of the General Programming Boards category; I have the following problem: My program is supposed to read data from files to an array. The files are ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    5

    reading multiple files in C

    I have the following problem: My program is supposed to read data from files to an array. The files are numbered: capture[1].bmp,capture[2].bmp and so on. There are 24 of those files, and I really don't want to do the same step 24 times. Is there a way to write a loop along the lines of

    if i want to specify where my file is existing........................

    Code:

    Code:
    for (int i=1; i<25, i++);
    {
    fp=fopen("c:\capture[i].bmp", "rb");
    
    fread(&ch,sizeof(ch),1,fp);
    	
    .....
    }
    In other words, is there a way to insert the "i" variable into the filename?



    Thank you for your insights.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    We did this already - Reading multiple files in C
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. header files and multiple files
    By Dedalus in forum C Programming
    Replies: 5
    Last Post: 06-16-2009, 10:21 AM
  2. Replies: 5
    Last Post: 02-25-2008, 06:35 AM
  3. Windows shell commands - multiple files
    By Magos in forum Tech Board
    Replies: 3
    Last Post: 02-28-2006, 01:56 AM
  4. Opening Multiple Files in sequence
    By wujiajun in forum C++ Programming
    Replies: 7
    Last Post: 01-16-2006, 08:47 PM
  5. opening multiple files sequentially
    By moonwalker in forum C Programming
    Replies: 5
    Last Post: 08-20-2002, 10:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21