Thread: intereacting with fily system in c

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    486

    intereacting with fily system in c

    Hey guys,

    I have a list of several thousand files that I need to merge selectively into one file. The files are in three categories, called

    a????.dat
    e????.dat
    i????.dat

    where ???? is an integer that increases linearly, ei

    a0001.dat
    a0002.dat
    ...etc

    I am wondering how I can build a loop that opens these files in order based on the index. Basically my question is, how do I turn the index I am using in my for loop into a string of four integers that ends in my index and then gets .dat appended to it?

    for example, if my index == 108, then the string I need would be

    0108.dat, and I could say

    Code:
    afile = fopen("strcat(a,indexstring)",r");
    Also, I hae never done system calls in C. How can I call the file system to find out how many of these files there are in the current directory at runtime? I am googling this as we speak, so no smartass comments lol, I just thought posting here might speed up the search.

    I am just starting the code now, so suggestion are appreciated in the 20 minutes before I go home from work

    I'll post more details tomorrow as my code evolves.

    EDIT: looks like system() is what I want (go figure?)

    would sprintf with a format string to force 4 digits work to make the index a string?
    Last edited by KBriggs; 06-25-2009 at 02:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Operating System
    By Houssen in forum C Programming
    Replies: 18
    Last Post: 04-22-2008, 12:51 PM
  2. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  3. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  4. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM