ASingerMustDie
Programmer
Hi All
Sorry to bother you with something surely so trivial...
I am attempting to read the first 4 bytes of a file and ensuring that it reads "RIFF" (perhaps for obvious reasons).
I am using ReadFile to achieve this, the problem being that the buffer I read into seems to have an extra (null?) character appended to it, or so it appears when I attempt to debug. I know that character arrays are terminated by a null character, but if this is what is happening, how do I then compare the buffer to the string "RIFF"?
The code I have is (chopped for ease of reading)...
char waveBuffer[4];
DWORD waveRead;
HANDLE waveHandle;
//Assume file is opened
ReadFile(waveHandle, &waveBuffer, 4, &waveRead, NULL);
if (!strcmp(waveBuffer, "RIFF")
{
//Is Good;
}
else
{
//Is not good
}
I cant manage to have it work for files that DO begin with the four characters RIFF. Why is this?
Any help would be most appreciated.
ASMD
PS And why-oh-why when I opt to click the Help menu am I told that a required component is missing and that I must reinstall?
Sorry to bother you with something surely so trivial...
I am attempting to read the first 4 bytes of a file and ensuring that it reads "RIFF" (perhaps for obvious reasons).
I am using ReadFile to achieve this, the problem being that the buffer I read into seems to have an extra (null?) character appended to it, or so it appears when I attempt to debug. I know that character arrays are terminated by a null character, but if this is what is happening, how do I then compare the buffer to the string "RIFF"?
The code I have is (chopped for ease of reading)...
char waveBuffer[4];
DWORD waveRead;
HANDLE waveHandle;
//Assume file is opened
ReadFile(waveHandle, &waveBuffer, 4, &waveRead, NULL);
if (!strcmp(waveBuffer, "RIFF")
{
//Is Good;
}
else
{
//Is not good
}
I cant manage to have it work for files that DO begin with the four characters RIFF. Why is this?
Any help would be most appreciated.
ASMD
PS And why-oh-why when I opt to click the Help menu am I told that a required component is missing and that I must reinstall?