English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i'm writing a program that handles a list of files. i don't know what the files are named. what i need to know is something like all the files ending in *.txt in a specific folder.

also, i would appreciate if someone could give me a link to a tutorial or something for things like this (file handling).

2007-03-29 13:11:05 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

you can use FindFirst(), and FindNext() functions. the link below isnt the greatest example of how to use them, but if you have some time you could probably find better examples.

2007-03-30 02:30:30 · answer #1 · answered by justme 7 · 0 0

You can use the opendir(3) and readdir(3) C library calls to open a directory and iterate through files directly, or use glob(3) to do the pattern matching automatically.
Those are part of the POSIX interface, so they should be available on most systems.

2007-03-29 20:24:42 · answer #2 · answered by undercoloteal 3 · 0 0

The exact way to do this will depend on your operating system. For example, if you are in Windows, then you can fork a process and run the command "dir *.txt > blah.dat". Then, your C++ program can open blah.dat and parse it to find the names of the files.

This is one way to do it. There might be some Win32 system system calls that do the same thing. I suggest you comb through MSDN if you're running on Windows, and using the UNIX man pages if you're running on UNIX. If you can't find anything then I think the above way will do the job.

2007-03-29 20:19:25 · answer #3 · answered by icnintel 4 · 1 1

fedest.com, questions and answers