Thread: Help with strcmp!

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question 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?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    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);
    }

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Thank!

    Thanks for the help!
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fucntion returns -1, Why?
    By Taper in forum C Programming
    Replies: 16
    Last Post: 12-08-2008, 06:30 PM
  2. help with switch statement
    By agentsmith in forum C Programming
    Replies: 11
    Last Post: 08-26-2008, 04:02 PM
  3. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 12:07 PM
  4. help with strcmp
    By blork_98 in forum C Programming
    Replies: 8
    Last Post: 02-21-2006, 08:23 PM
  5. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 11:04 AM