Original Post
My call to cin.getline isn't doing what it's supposed to. It immidiatly returns, without waiting for input. Here's a code snippet:
When this function runs, it just shows the current title, display's do I want to change it, and returns.
What am I doing wrong here? I don't see a reason for it to not work.
Edited by - Ivko on November 29, 2001 10:14:54 PM
char confirm[5];
char newtitle[100];
cout << "Current Title: " << CFGFile.title << "\n";
cout << "Do you want to change it (y/n)? " << flush;
cin.getline(confirm, 4);
if(strcmp(confirm, "y") == 0) {
cout << "Change to: ";
cin.getline(newtitle, 100, '\n');
if(strlen(newtitle) >= 100) {
cout << "Maximum title length is 100 characters.\n";
DoTitle();
} else {
//newtitle[strlen(newtitle)-1] = '\0';
strcpy(CFGFile.title, newtitle);
}
}
|