Yeah so my previous post was correct.
Start by just printing the files without recursion to see what I mean:
HANDLE hfile=FindFirstFileA("C:\\Program Files\\*.*", &ffd);
cout << ffd.cFileName << endl;
Notice how you get two extra directories here:
Windows puts these in every directory (except for top-level directories, apparently). "." is this directory, and ".." is the parent directory.
If you are iterating over all files... you want to ignore these entries
. So you'll have to explicitly look for them and skip over them.
You're using the wrong character type. FindFirstFile takes TCHAR strings. If you are using regular char strings, you should be using:
(notice how they all end with and extra 'A'). Details here:
Also, remember to close your handles with FindClose when you're done with them.
And consistent indenting really makes it easier to read the code.