-
Help with getch();
Why does getch(); have to get the character before it will output the cout<< before it???
void displayalbum(NODE* &head,apstring &album)
{
NODE *node=head;
int count=0;
cout<<"\n";
for(node;node;node=node->next)
{
if(node->album==album)
{
cout<<node->artist<<endl;
cout<<" "<<node->album<<endl<<" Loaned : "<<node->loaned<<endl;
if(node->loaned=="y")
{
cout<<" To : "<<node->towho<<endl;
}
cout<<"\n";
count++;
}
}
if(count==0)
cout<<"* CD NOT FOUND *\n\n";
cout<<"Press any key to continue.";
getch();
cout<<"\n";
return;
}
-
-
I tried using _getch(); but it gave me the same problem... any more suggestions???
-
The problem you are having is because cout is buffered....
cout<<'\n'; // this does not flush the buffer.
cout<<endl; // this on the other hand will.
to flush specifically without using a newline ....
cout<<"Are you starting to get it??"<<flush;
cout will also be flushed on any call to cin (providing you have not untied the streams).
-
Try
[/CODE]
cout<<"Press any key to continue.Test" << endl << flush ;
getch();
[CODE]
I think you just need to force (flush) the output.
dang
-
Thanks, that fixed the problem...