#The console closes automatically.

42 messages · Page 1 of 1 (latest)

radiant hinge
#

Even when using system(“pause”) or cin.get(); in CUI, the console closes at random times.

pale thistleBOT
#

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.

radiant hinge
#

When using PlaySound, the console closes while music is playing (the music continues to play).

radiant hinge
#

When the program is executed, the console closes after a few seconds (random)

sudden widget
#

wdym "closes"???

#

the terminal will only close either you close it or something on the terminal crash

#

it will not close by random means

radiant hinge
#

i mean random time

sudden widget
#

how are you running the code

radiant hinge
#

build release and double clicking file

sudden widget
#

that's why....

radiant hinge
#

Closes automatically without having to close it yourself or press a button

sudden widget
radiant hinge
#

visual studio 2022

sudden widget
#

you should be able to compile and run it from he visual studio it's self

radiant hinge
#

Yes. That way the problem will not occur without closing

#

however, with this method, only i can execute it

sudden widget
#

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

radiant hinge
#

thanks ill try this

#

Unfortunately, the situation remains unchanged 🙁

#

Or is this my computer issues??

sudden widget
#

no

#

show me what you did

radiant hinge
#
{
    std::cout << "Playing\n";
    
    PlaySound(TEXT("test.wav"), NULL, SND_SYNC);

    std::string temp;
    std::cin >> temp;

    return 0;

}```
pale thistleBOT
#

@radiant hinge

It looks like you may have code formatting errors in your message

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

Markup

```cpp
int main() {}
```

Result
int main() {}
radiant hinge
#

music is keep playing but console closes

#

while playing music

sudden widget
radiant hinge
#
#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;

}```
pale thistleBOT
#

@radiant hinge Has your question been resolved? If so, type !solved :)

sudden widget
radiant hinge
#

yes 😭

#

system("pause") also dosent working..

#

i googled already but idk why it dosent work for me

sudden widget
#

can you cast the string into LPCTSTR???

radiant hinge
#

okay ill try

#

now its work

#

thanks for help me

#

!solved

pale thistleBOT
#

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