open files in a loop in C

This is a discussion on open files in a loop in C within the C Programming forums, part of the General Programming Boards category; I have to open many small files in C. But the files are in the form a.001, a.002, .....a.00n. I ...

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

    open files in a loop in C

    I have to open many small files in C. But the files are in the form a.001, a.002, .....a.00n.
    I lke to open files in a loop.
    like when int n = 1 open a.001
    upto n=n open a.00n.

    Can you please help me.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    sprintf the filename and the number together and then use it to call fopen.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    4
    thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loop the loop - feeling foolish
    By estos in forum C Programming
    Replies: 2
    Last Post: 04-07-2007, 03:45 AM
  2. Open GL header files
    By Rune Hunter in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2005, 02:10 AM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM
  4. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM
  5. Replies: 7
    Last Post: 10-15-2002, 11:55 PM

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