File searching function

This is a discussion on File searching function within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi, I am working on a program (DOS). I need a function that finds all files with a certain extension ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    File searching function

    Hi, I am working on a program (DOS). I need a function that finds all files with a certain extension (ie *.txt) in a folder. It should return an array of pointers to these files, or something similar.

    Does this function exist (I took a quick look in fstream.h, didn't find it) or do I have to make my own? If so, can you give me a hint how I would start?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    403
    some systems implement a findfirst function, look for it as _findfirst maybe the compiler should explain how to use it? also i've seen somewhere a function called listdir that had syntax something like this
    PHP Code:
        listdir(char namechar typechar dirbool branch); 
    name was the actuall name (NULL == *)
    type was the extension (NULL == *)
    dir was the directory
    branch was if you wanted to recurse subdirectories.

    But listdir may have been included in some library i had, or worst case scenario it could have been a different language (pascal maybe?)

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    yes

    I found the Findfirst and Findnext functions. I'll check them out tomorrow. Thanks a lot.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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