C++ code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: C++ code

  1. #1
    Join Date
    Apr 2008
    Posts
    1

    C++ code

    I have this code but the umemba, loser, and winner sounds wont play...can somone help me...

    #include <windows.h>
    #include<iostream>

    using namespace std;

    DWORD WINAPI dwThread(LPVOID);
    DWORD WINAPI dwUmemba(LPVOID);
    DWORD WINAPI dwLoser(LPVOID);
    DWORD WINAPI dwWinner(LPVOID);
    int main()
    {
    HANDLE hThread;
    while(hThread)
    {
    hThread=CreateThread(NULL,1,dwThread,0,1,NULL);
    WaitForSingleObject(hThread,1);
    }
    char lname[34];
    int number;
    char name[35];
    cout<<"Please enter your name."<<endl;
    cin>>name;
    cout<<"enter 3 or 4"<<endl;
    cin>>number;

    if(number==3)
    {
    HANDLE hThread;
    while(hThread)
    {
    hThread=CreateThread(NULL,1,dwUmemba,0,1,NULL);
    WaitForSingleObject(hThread,1);
    }

    }
    else if (number==4)
    {
    HANDLE hThread;
    while(hThread)
    {
    hThread=CreateThread(NULL,1,dwLoser,0,1,NULL);
    WaitForSingleObject(hThread,1);
    }

    }
    else
    {
    HANDLE hThread;
    while(hThread)
    {
    hThread=CreateThread(NULL,1,dwWinner,0,1,NULL);
    WaitForSingleObject(hThread,1);
    }

    PlaySound("winner.wav",NULL,SND_FILENAME | SND_ASYNC);
    }

    cout<<"You loser"<<name<<endl;

    cout<<"please enter your last name"<<endl;
    cin>>lname;
    return 0;
    }

    DWORD WINAPI dwThread(LPVOID)
    {
    PlaySound("tetris.wav",NULL,SND_FILENAME);
    ExitThread(0);
    }

    DWORD WINAPI dwUmemba(LPVOID)
    {
    PlaySound("umemba.wav",NULL,SND_FILENAME);
    ExitThread(0);
    }
    DWORD WINAPI dwLoser(LPVOID)
    {
    PlaySound("loser.wav",NULL,SND_FILENAME);
    ExitThread(0);
    }
    DWORD WINAPI dwWinner(LPVOID)
    {
    PlaySound("winner.wav",NULL,SND_FILENAME);
    ExitThread(0);
    }

  2. #2
    Join Date
    May 2007
    Posts
    843
    Of course, it won't play the sound for umeba and loser because you didn't call the function play sound.

Similar Threads

  1. Jupitermedia Legal Notice -- NO PERMISSION TO USE CODE SAMPLES?!
    By Noryk Rekrap in forum Talk to the Editors
    Replies: 3
    Last Post: 08-23-2007, 04:56 PM
  2. wot is CLR
    By lostguy in forum .NET
    Replies: 8
    Last Post: 04-03-2002, 07:41 PM
  3. .NET equals Efficiency
    By Kevin in forum .NET
    Replies: 150
    Last Post: 03-04-2002, 06:40 PM
  4. Another Language
    By Steven Bell in forum .NET
    Replies: 260
    Last Post: 06-01-2001, 05:32 PM
  5. error code in JSP(please chek the code)
    By satish in forum Java
    Replies: 1
    Last Post: 09-22-2000, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center