Alternative function in iostream.h for getch() of conio.h?

后端 未结 10 1038
无人共我
无人共我 2020-11-30 09:55

I\'m trying to hold the screen on my output using the header file , but I don\'t know any equivalent function to the getch() &

10条回答
  •  一生所求
    2020-11-30 10:34

    Late answer, you can use std::cin.get(), this should work with most compilers. If that doesn't work, try adding another.

    int main () {
    
        // ...
    
        std::cin.get();
        std::cin.get();
        return 0x00;
    }
    

    Using system("PAUSE") is only available on Windows and is a bad programming habit. The reason for this is it literally pauses or freezes your program as opposed to just waiting for an input. ie. a keypress to exit.

提交回复
热议问题