#The console closes automatically.
42 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
When using PlaySound, the console closes while music is playing (the music continues to play).
what do you mean?
When the program is executed, the console closes after a few seconds (random)
wdym "closes"???
the terminal will only close either you close it or something on the terminal crash
it will not close by random means
i mean random time
how are you running the code
build release and double clicking file
that's why....
Closes automatically without having to close it yourself or press a button
what ide are you using???
you should be able to compile and run it from he visual studio it's self
Yes. That way the problem will not occur without closing
however, with this method, only i can execute it
try running the program through your terminal or you can add std::string temp;std::cin >> temp; at the end of the program to make the program only close when you press enter
thanks ill try this
Unfortunately, the situation remains unchanged 🙁
Or is this my computer issues??
{
std::cout << "Playing\n";
PlaySound(TEXT("test.wav"), NULL, SND_SYNC);
std::string temp;
std::cin >> temp;
return 0;
}```
@radiant hinge
Note: Make sure to use back-ticks (`) and not quotes (')
Note: Make sure to specify a highlighting language, e.g. `cpp`, after the back-ticks
```cpp
int main() {}
```
int main() {}
show me the entire code
#include <iostream>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
int main()
{
std::cout << "Playing\n";
PlaySound(TEXT("test.wav"), NULL, SND_SYNC);
std::string temp;
std::cin >> temp;
return 0;
}```
@radiant hinge Has your question been resolved? If so, type !solved :)
this doesn't do the thing???
yes 😭
system("pause") also dosent working..
i googled already but idk why it dosent work for me
can you cast the string into LPCTSTR???
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity