![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
getline() skipping. help?
hey guys, i have a console program into which i want to put a menu. I have a partly working menu, but it skips the getline part... heres the code:
if (op == 1)
{
bruteforce_input(); //<----- skips this part
//other code...
}and then the function: void bruteforce_input ()
{
cout << "\n\n\n\n\t\t To begin Brute Forcing a ceasar shift,\n\t\t enter the cipher text:\n\n\t\t>";
getline(cin,ciphertext);
cout << "\t\t --------------------------------------\n\n\n";
cls();
cout << "\n\n\t\tStarting the brute force...\n\n\n";
}
__________________
www.heldtogether.co.uk |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Have you done previous input? You probably have a newline in the buffer that is satisfying the call. Put cin.sync () prior to the call. After the call, TEST CIN FOR FAILURE. That would be, "if (!cin.good ()) // Bad news ". Failing to to this is the hallmark of a newb or a schlock.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: May 2005
Location: Woo - Boot Sector!
Posts: 294
Rep Power: 4
![]() |
Yeah i have previous input... thanks.
Right suppose you could call me a schlock...
__________________
www.heldtogether.co.uk |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|