Home > Mobile >  How to make a C console app wait before exiting?
How to make a C console app wait before exiting?

Time:05-07

It seems that I can't find any solution to this problem, so I'm asking you. C doesn't support iostream and Console.Readkey unless i did something wrong, so please help!

CodePudding user response:

C

 getc(stdin);

C

std::cin.get();

Worst Example Listed on Many Websites

system("pause"); //never use this

See what's wrong with system("pause");

CodePudding user response:

You can use getchar() or getc(stdin) to read a character. The console is line buffered by default (at least on Linux) so it means it will wait for enter.

  • Related