hi!
this is probably a simple question: how do i list the contents of a directory?
i didn't found any useful references because they were either overkill-complicated or the headers didn't exist ;(
thanks.
hi!
this is probably a simple question: how do i list the contents of a directory?
i didn't found any useful references because they were either overkill-complicated or the headers didn't exist ;(
thanks.
For which platform? Alternatively, use the Boost Filesystem library.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
windows
Check out the FAQ (link in the blue bar above).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
you mean this?
http://faq.cprogramming.com/cgi-bin/...&id=1044780608
visual studio 2008 express cant seem to find <dirent.h>
edit: found the windows example... i guess it could be easier tho?
got it working now.
thanks
Last edited by Devils Child; 03-10-2009 at 06:35 AM.
That is the right FAQ entry, but you probably want the Win32 version, rather than the Linux/Unix/Posix version of the code, which is the third (or so) bit of code posted on that page.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
200 lines of code.
i dumped them down to this:Code:#include <stdio.h> #include <stdlib.h> #include <windows.h> #include <iostream> using namespace std; int main() { WIN32_FIND_DATA info; HANDLE h = FindFirstFile("*.*", &info); do { if (strcmp(info.cFileName, ".") != 0 && strcmp(info.cFileName, "..") != 0) { cout << info.cFileName << endl; } } while (FindNextFile(h, &info)); FindClose(h); cin.get(); }