'How to make a C console app wait before exiting?

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!



Solution 1:[1]

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");

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2