3 questions, one thread....

This is a discussion on 3 questions, one thread.... within the C++ Programming forums, part of the General Programming Boards category; Okay.. .How do i play sounds and music on c++? In MSW logo it's just: playwave 'c:/mydocu~1/sounds/beep.wav But in c++ ...

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Unhappy 3 questions, one thread....

    Okay.. .How do i play sounds and music on c++?
    In MSW logo it's just:
    playwave 'c:/mydocu~1/sounds/beep.wav

    But in c++ it won't work for some reason....(sarcaasm)

    what should i include to use the diffdate()
    command?

    How do i clear the screen?

    Stupid, i know.. i suck at programming, and when i try to find this on the web, i get basic, logo, perl, java, anything but c++.
    This war, like the next war, is a war to end war.

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    How do i clear the screen?

    Code:
    #include <stdlib.h>
    
    int main ()
    {
    
    cout <<"This text will be cleared.";
    
    system("cls");
    
    return 0;
    
    }

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072

    Re: 3 questions, one thread....

    Originally posted by Blizzarddog
    Okay.. .How do i play sounds and music on c++?
    Code:
    #include <windows.h>
    ...
    //Notice the \\ instead of \
    PlaySound("C:\\mysound.wav",NULL,SND_FILENAME);
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Thank you y'alll. The cls works. however the sound doesn't agree with my include files...
    I was using #include <stdlib.h>
    and got this error:
    warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.


    I change it to <cstdlib>

    and get the same thing.
    This war, like the next war, is a war to end war.

  5. #5
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    if i delete it, i get the same warning... i get rid of the
    PlaySound("C:\\world.wav",NULL,SND_FILENAME);
    it works
    This war, like the next war, is a war to end war.

  6. #6
    rpincher
    Guest
    This may be a silly question but you were using both the headers weren't you?

  7. #7
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    Originally posted by Blizzarddog
    Thank you y'alll. The cls works. however the sound doesn't agree with my include files...
    I was using #include <stdlib.h>
    and got this error:
    warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.


    I change it to <cstdlib>

    and get the same thing.
    what compiler are you using

    below your header files, try adding:

    using namespace std;

    see if that helps

  8. #8
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    PlaySound() uses windows.h AND the winmm.lib library. Include both and it will work. you can't use #include <winmm.lib> to include library files.. What compiler are you using?

  9. #9
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    the code:

    This is my code:

    ______________________________________
    #include <iostream.h>
    #include <cstdlib>
    #include <windows.h>
    using namespace std;
    int Wait ( int Seconds );

    int main ( void )
    {
    PlaySound("C:\\world.wav",NULL,SND_FILENAME);
    cout << "You like the juice, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice is good, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice is very good, eh?\n";
    Wait(3);
    system("cls");
    cout << "I go get you more juice\n";
    Wait(3);
    system("cls");
    cout << "I got the juice\n";
    Wait(3);
    system("cls");
    cout << "The juice\n";
    Wait(3);
    system("cls");
    cout << "You don't like the juice?\n";
    Wait(3);
    system("cls");
    cout << "The juice no good, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice very bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "Me taste the juice\n";
    Wait(3);
    system("cls");
    cout << "You right, the juice bad\n";
    Wait(3);
    system("cls");
    cout << "The juice very bad\n";
    Wait(3);
    system("cls");
    cout << "Me throw up now\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch\n";
    Wait(3);
    system("cls");
    cout << "You don't like the juice sketch?\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch very bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "Me watch the juice sketch...\n";
    Wait(3);
    return 0;
    }


    int Wait ( int Seconds )
    {
    clock_t endtime = clock() + Seconds * CLOCKS_PER_SEC;
    while ( ( clock() < endtime ) );
    return 0;
    }
    Last edited by Blizzarddog; 10-16-2002 at 08:53 AM.
    This war, like the next war, is a war to end war.

  10. #10
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I'm typing it in Bloodshed's DEV ++
    and using the gnu compiler
    This war, like the next war, is a war to end war.

  11. #11
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Originally posted by rpincher
    This may be a silly question but you were using both the headers weren't you?
    No, i was origanally using stdlib.h because DEV++ automatically has this when booted:

    #include <iostream.h>
    #include <stdlib.h>

    int main()
    {

    SYSTEM("PAUSE")
    Return 0;
    }

    And it's not a silly question, i've done it before!
    This war, like the next war, is a war to end war.

  12. #12
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Thumbs down

    I learned to use using namespace std;
    from c++ primer plus.
    And it don't work.
    i mean, it works, but doesn't make the program work beteerr
    bblaasted keebord!
    This war, like the next war, is a war to end war.

  13. #13
    Registered User GreenCherry's Avatar
    Join Date
    Mar 2002
    Posts
    65
    You forgot to use code tags!

    Code:
    #include <iostream.h>
    #include <cstdlib>
    #include <windows.h>
    using namespace std;
    int Wait ( int Seconds );
    
    int main ( void )
    {
    PlaySound("C:\\world.wav",NULL,SND_FILENAME);
    cout << "You like the juice, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice is good, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice is very good, eh?\n";
    Wait(3);
    system("cls");
    cout << "I go get you more juice\n";
    Wait(3);
    system("cls");
    cout << "I got the juice\n";
    Wait(3);
    system("cls");
    cout << "The juice\n";
    Wait(3);
    system("cls");
    cout << "You don't like the juice?\n";
    Wait(3);
    system("cls");
    cout << "The juice no good, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice very bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "Me taste the juice\n";
    Wait(3);
    system("cls");
    cout << "You right, the juice bad\n";
    Wait(3);
    system("cls");
    cout << "The juice very bad\n";
    Wait(3);
    system("cls");
    cout << "Me throw up now\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch\n";
    Wait(3);
    system("cls");
    cout << "You don't like the juice sketch?\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "The juice sketch very bad, eh?\n";
    Wait(3);
    system("cls");
    cout << "Me watch the juice sketch...\n";
    Wait(3);
    return 0;
    }
    
    
    int Wait ( int Seconds )
    {
    clock_t endtime = clock() + Seconds * CLOCKS_PER_SEC;
    while ( ( clock() < endtime ) );
    return 0;
    }
    I have a rabbit in my pants! Please be happy for me.

  14. #14
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    i don't understand code tas, i don't see any difference in the code if there is any....
    This war, like the next war, is a war to end war.

  15. #15
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    why use a system call when you can use clrscr();, dont use system calls unless you really need to, they make porting difficult.
    Monday - what a way to spend a seventh of your life

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shared memory implementation using thread
    By kumars in forum C Programming
    Replies: 5
    Last Post: 06-18-2008, 04:24 AM
  2. user thread library
    By Eran in forum C Programming
    Replies: 4
    Last Post: 06-17-2008, 01:44 AM
  3. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 04:34 AM
  4. Replies: 12
    Last Post: 05-17-2003, 05:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21