-
Help with strcmp!
I am making a simple .wav file player, and I have a file system-like thing in a listbox. I want to detect if the selected file contains .wav:
I tried:
char wav is declared as ".wav";
if(!strcmp(szFile, wav))
{
PlaySound(szBuffer, NULL, SND_FILENAME | SND_ASYNC);
}
else
{
MessageBox(hwnd, "Must be valid .wav format!", "Error", MB_OK + MB_ICONINFORMATION);
}
but I get the error message under the "else" statement. How do I use strcmp to check the string?
-
I think you need to use strstr() instead.
if(strstr(szFile, wav) != NULL)
{
PlaySound(szBuffer, NULL, SND_FILENAME | SND_ASYNC);
}
else
{
MessageBox(hwnd, "Must be valid .wav format!", "Error", MB_OK + MB_ICONINFORMATION);
}
-
Thank!