MS Visual Studio 2005 - VC++ - pausing output to screen  
Author Message
lbamburg





PostPosted: Visual C++ General, MS Visual Studio 2005 - VC++ - pausing output to screen Top

I am working on an assignment for my C++ class and have hit a snag, I hope someone here will be able to help me with this.

The program is a Mortgage Calculator, which I have working for the most part. However, I am supposed to display the information for each payment over the term of the loan. I also need to pause the screen after so much information is displayed and wait for the user to press any key before the screen continues.

My question is:

How do I pause the screen after so many lines of code are displayed

This is what I have tried before, but is did not work at all.

bool anyKey = false;

if ((i+1) % 12 == 0)

{

getch();

cout << "Press any key to continue ";

cin >> anyKey;



Visual C++13  
 
 
Bite Qiu - MSFT





PostPosted: Visual C++ General, MS Visual Studio 2005 - VC++ - pausing output to screen Top

Hi, Lbamburg

I tried your way, and it seems works by my understanding of your question :)

#include "stdafx.h"

#include <iostream>

#include <conio.h>

using namespace std;

#define SCREEN_VOLUME 15

int main()

{

for(int i=0;i<10000;i++){

cout << "Something you want to display" << endl;

// check if it has reach the bottom of screen

if( (i+1)%SCREEN_VOLUME==0 ){

cout << "Press any key to continue";

_getch();

cout << endl;

}

}

return 0;

}

if this doesn't help, please follow up and let me know, thanks.

Thanks

Bite



 
 
lbamburg





PostPosted: Visual C++ General, MS Visual Studio 2005 - VC++ - pausing output to screen Top

Thanks Bite,

This did work to make the screen pause, but it does not stop displaying information when the number of records has been displayed. I tried changing the line

for(int i=0;i<10000;i++){

to

for(int i=0;i<400;i++){

and it does not stop at 400, but starts again at 1. I know have an endless loop, but this may be in part because of an error on my part. My calculations are still not looping as they should so the balance never reaches 0.00 which is where it should stop.

The first line of information is correct, but it does not recalculate with the new information as it should.

Anyway thanks for your help, it is much appreciated.

Lbamburg


 
 
Dav? S. A???????





PostPosted: Visual C++ General, MS Visual Studio 2005 - VC++ - pausing output to screen Top

You could do a check in the for loop and do a force break.

if (i == 400)
{
break;
}
else
{
// ... do nothing
}