English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

2007-11-15 14:56:52 · 6 answers · asked by ted-m 2 in Computers & Internet Programming & Design

#include

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++

2007-11-15 15:05:00 · update #1

6 answers

get in the habit of using getch() because it will work on all platforms (windows, unix, linux).

system("pause"); is Microsoft only.

2007-11-15 15:08:15 · answer #1 · answered by Big John Studd 7 · 0 0

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...

2015-08-12 21:38:56 · answer #2 · answered by Junie 1 · 0 0

C Pause

2016-12-16 18:25:51 · answer #3 · answered by ? 4 · 0 0

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()

2007-11-15 15:00:43 · answer #4 · answered by mdigitale 7 · 0 0

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.

2007-11-15 15:04:37 · answer #5 · answered by mascix 2 · 0 0

Just hit F5 or just click The green play button on the top.

2016-03-17 13:23:52 · answer #6 · answered by Anonymous · 0 0

Just add a getch(); before the last } of main. You will be fine.

2007-11-15 15:00:51 · answer #7 · answered by Anonymous · 0 0

very good question

2016-08-26 06:58:11 · answer #8 · answered by ? 4 · 0 0

fedest.com, questions and answers