There's this problem I have when writing small 'dos applications'.
It may sound dumb, but I want to know the best way to let someone( using your program) enter a key to proceed.
Here's an example of a simple code I wrote..
-------------------------------------------
#include <iostream.h>
#include <string.h>
int main()
{
char name[50];
char confirm[1];
cout<<"Please enter your name: ";
cin.getline(name, 50, '\n');
strlwr(name);
cout<<"Hello "<<name<<" Do you wish to proceed? y/n?";
cin.getline(confirm, 1, '\n');
if(!strcmpi("n", confirm))
{
cout<<"Press Return to quit";
return 0;
}
else
{
cout<<"It works!!";
return 0;
}
}
-------------------------------------------
All works fine, untill I have to press enter to confirm my procedure. The dos screen just disappears becouse the code ends immediately. Why does it skip the cout function each time I run a dos application? (Yes I tried using cin.get(); but it doesn't work) Is there any other function but cin.get(); to let the user press a key to proceed? And when someone replies to this thread, is there any other way to write the same code?