first off i'm using gcc with codeblocks
ok, that said, here's my question
how do i read for files that are in the same dir as my program, all i want it to do is read, and save a list of filenames
I hope this is what you looking for.
It works with Dev-cpp and Visual C 6.0, so it should work with Code::Blocks :)
/*
FindFiles
Dev_c++ example by Rbraz
*/
#include <windows.h>
#include <winbase.h>
#include <iostream>
using namespace std;
void FindFiles(char *path)
{
WIN32_FIND_DATA fileinfo; // file information struct
HANDLE search = FindFirstFile(path, &fileinfo);
if(INVALID_HANDLE_VALUE == search) return;
do
{
cout << "FileName = " << fileinfo.cFileName << endl; // Here you can do whatever you want with "fileinfo.cFileName" (display. save etc...)
}
while (FindNextFile(search, &fileinfo));
FindClose(search);
}
int main(int argc, char *argv[])
{
FindFiles("*"); // Search in the same path of your executable
// FindFiles("c:\\*"); // Search in another path
system("PAUSE");
return EXIT_SUCCESS;
}
hey!! thats awesome! i havent had a chance tot test it out yet, but i will when i get on my main machine?
also, i was wondering where would be a good place to learn more stuff like that ((windows type stuff)
thnkx for t hte help
-xteraco
I don't know a specific place to learn it, but I have the Win32 API Reference (http://flatassembler.net/docs/win32hlp.zip) that helps a lot, and when I have troubles with some command I try to serch help in the net.