News:

Pretty crazy that we're closer to 2030, than we are 2005. Where did the time go!

Main Menu

[C/C++] FindFile function...issues

Started by ink, February 12, 2006, 04:02:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ink

This is a sample code from MSDN for the findfile function that I edited a little (probably messed it up since I dont know squat about c) but yeah, im looking for guidence/direction



#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <stdio.h>

int main()
{
char findFile [80];
WIN32_FIND_DATA FindFileData;
HANDLE hFind;

printf ("Enter file to find: ");
scanf ("%s",findFile);

hFind = FindFirstFile(findFile, &FindFileData);

if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid File Handle. GetLastError reports %d\n",
GetLastError ());
return (0);
}
else
{
printf ("The first file found is %x\n",
FindFileData.cFileName);
FindClose(hFind);
return (1);
}
}




Problem I'm having at the moment is that it either returns saying its an invalid handle or that "The first file found is 12fe1c" everytime  ???

zorm

It totally helps if you give a problem or something that you are having.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

ink

#2
Scratch that problem, I had to change  the %x to %s
which brings up another question, what do %d, %s, and %x represent?


Um... scratch that question as well, and incase anybody else didn't know:
%d returns decimal value, %x returns hex value and %s returns string value, I think?

Sidoh