Mail Archives: djgpp/1998/02/17/06:34:30
In this bit of code, the user can type as long as he wants until
he/she types the '9' key. How can I make the program terminate on an
'alt-x' or 'F10', or anything besides a "regualr key". Thanks in
advance to anyone who can help me.
Here's the code:
#include <fstream.h>
#include <stdio.h>
#include <conio.h>
main()
{
//Declarations--
char avar,filename[12],phrase;
int count;
fstream ptr;
//---------------
clrscr();
cout << "Filename? ";
gets(filename);
cout << "\nWhat information do you want in " << filename << " ?\n";
ptr.open(filename, ios::out);
while ((phrase = getche()) != '9')
{
ptr << phrase;
}
ptr.close();
- Raw text -