Trending News
how to make a C/C++ program pause?
ok so I'm trying to learn C and C++, and whenever I execute the program it runs in the blink of an eye and I don't have time to see what it says, I remember there being a pause command or something that I could put in there somewhere that would wait for me to press enter, can you tell me where to put it and exactly what it's called? thank you
#include <stdio.h>
int main()
{
printf("This is a line of text to output.\n");
printf("And this is another ");
printf("line of text.\n\n");
printf("This is a third line.\n");
return 0;
}
(thats an example of the code that the program has (its a very basic program) and please repost that with the added function or whatever it's called in C/C++
8 Answers
- Big John StuddLv 71 decade agoFavorite Answer
get in the habit of using getch() because it will work on all platforms (windows, unix, linux).
system("pause"); is Microsoft only.
- 6 years ago
This Site Might Help You.
RE:
how to make a C/C++ program pause?
ok so I'm trying to learn C and C++, and whenever I execute the program it runs in the blink of an eye and I don't have time to see what it says, I remember there being a pause command or something that I could put in there somewhere that would wait for me to press enter, can you tell me...
Source(s): program pause: https://biturl.im/gprui - mdigitaleLv 71 decade ago
There are a variety of ways -- basically you just need something that will cause the process to block.
One of these will work:
-Try reading in some input
-Use the sleep() command
-Use getch()
- How do you think about the answers? You can sign in to vote the answer.
- 1 decade ago
if the operating system is windows you can use
system("pause");
this function was declared in system.h I gues you should include the file. and for any operating system you can use scanf.
- Anonymous5 years ago
Just hit F5 or just click The green play button on the top.
- Anonymous1 decade ago
Just add a getch(); before the last } of main. You will be fine.