Results 1 to 3 of 3
Hi everybody,
Does anyone know a clean way to get a filelisting from a given dir in linux?
I need to edit multiple files in a C++ prog and I ...
- 03-17-2005 #1Just Joined!
- Join Date
- Feb 2005
- Location
- Groningen (NL)
- Posts
- 19
reading Directory contents (files) with C++
Hi everybody,
Does anyone know a clean way to get a filelisting from a given dir in linux?
I need to edit multiple files in a C++ prog and I couldn't find a solution on the net.
Many thanx
Pim
- 03-17-2005 #2Linux Newbie
- Join Date
- Oct 2004
- Location
- de
- Posts
- 103
A quick into the look GNU C Library documentation always helps. :)
http://www.gnu.org/software/libc/man...index.html#Top
http://www.gnu.org/software/libc/man...sing-Directory
And here's an example program (taken from the glibc doc):
-- FelixCode:#include <stddef.h> #include <stdio.h> #include <sys/types.h> #include <dirent.h> int main (void) { DIR *dp; struct dirent *ep; dp = opendir ("./"); if (dp != NULL) { while (ep = readdir (dp)) puts (ep->d_name); (void) closedir (dp); } else perror ("Couldn't open the directory"); return 0; }
- 03-17-2005 #3Just Joined!
- Join Date
- Feb 2005
- Location
- Groningen (NL)
- Posts
- 19
thanx!


Reply With Quote
