How exactly do I use the playsound function in C?

Updated on technology 2024-03-27
8 answers
  1. Anonymous users2024-02-07

    Method:

    The rand() function is used to generate random numbers, however, the internal implementation of rand() is implemented using the linear congruence method, which is a pseudorandom number and can be considered random within a certain range due to the long period.

    rand() returns a pseudo-random number (integer) with a range from 0 to rand max(32767).

    Before calling the rand() function, you can use the srand() function to set the random number seed, if the random number seed is not set, the rand() function will automatically design the random number seed to be 1 when it is called. The random seed is the same, and the random number generated each time will be the same.

    The header file required for the rand() function is:

    rand() function prototype: int rand(void);

    Use the rand() function to generate random integers within 1-100: int number1 = rand() 100;

    rand( ) in C++ should be lowercase, and the header file needs to be loaded.

  2. Anonymous users2024-02-06

    Is there a random function in C++?

    If it's rand, then you can.

    srand( (unsigned)time(null));Generate seeds.

    r = rand()%100;

  3. Anonymous users2024-02-05

    The first thing to do is to call a randomize();

    Let seed, then random(100); That's it.

  4. Anonymous users2024-02-04

    When using the playsound function, you need to add it after include (note: it cannot be added in front):

    #include

    #pragma comment(lib, "")playsound("c:\\windows\\media\\",null,snd_filename|snd_async);

  5. Anonymous users2024-02-03

    G++ I don't know if it's going to work. Link -lwinmm, I'm ms vc++

    Append the header file include

    #include

    #include

    #include

    #pragma comment(lib, "")void main()

    exit(0);}

  6. Anonymous users2024-02-02

    First of all, you don't need so many header files at all, just use it.

  7. Anonymous users2024-02-01

    It's included.

    Replace it with this: include

    #pragma comment(lib, "")void main()

  8. Anonymous users2024-01-31

    playsound(l"Song title", null, snd_filename | snd_loop | snd_async);

    And this should be put in the directory, the path is the solution after right-clicking in the Open in File Explorer option, and it is the target path.

Related questions
14 answers2024-03-27

DefWindowProc and WindowProc are both ** processing message API functions, and DefWindowProc handles messages that are not processed by WindowProc. However, in the scenario of your program, cmfcwnd is a subclass of cframewnd, and only calling defwindowproc cannot achieve all the cframewnd characteristic messages, and you must call the message handler of the parent class.

4 answers2024-03-27

define the function void f(int q, int w, int e=0);

e=0 is the default argument, when the function is called f(1,2), then e=0 >>>More

11 answers2024-03-27

using systme;

using ; >>>More

8 answers2024-03-27

You can use function pointers, such as:

voidfunction(int >>>More

6 answers2024-03-27

I majored in computer science, and I was embarrassed when I first learned C language, but I also had some experience. >>>More