Thread: File names

  1. #1
    Registered User
    Join Date
    Feb 2005

    File names

    Hi !

    I am writting a C program on unix platform.
    I need create many files with the same first part of the name but ending with increasing numbers like (file01, file02, file03...). Does someone know how to do that automatically ?
    Thanks for the help.


  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Use sprintf.
    for (i = 0;i < 100;i++)
        char file_name[PATH_MAX];
        sprintf(file_name, "file%02d", i);
        printf("File name is %s.\n", file_name);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File being filled with NULLs
    By Tigers! in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2009, 05:28 PM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. archive format
    By Nor in forum A Brief History of
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM