I need to open and walk through directories in C.
Can I use fopen like I'd do for files?
And how?
After haviong done this, I'd like to open all(!) files
in a directory (one after another or however) to seek
for keywords in them.
Hi,
Depending on your compiler look up 'findfirst(...)' and 'findnext(...)' or FindFirstFile(...) etc.
Good Luck,
Pappy Pappy
You learn somrthing everyday.
C has no native support for directory opening/traversing, so how you do this depends on the implementation. If you're in a DOS/Windows environment, take a look at findfirst() and findnext(). For *nix environments take a look at opendir() and readdir()
getenv() returns a pointer to a string that matches an environment variable specified in the 1st argument. For example, you might do:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.