getline

ok here is my issue (I'm sure it's something simple) this is a snipet of my code from main that calls the menu function that displays a menu of options. When I select 1 to enter data it skips right past the getline and never gives me an opportunity to type anything in?? If I did cout<<"Enter a #"<<endl; and then did a cin>>num; it would pause to let me type... but ..... please help thanks


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
menu();
cin>>menuoption;


    if (menuoption == 1)
    {
        system("cls");
        cout<<"Enter Fraction A: (proper format ** **/**)"<<endl;
        getline(cin, userinput);  
        F1.setfraction(userinput);
        wholenumber = F1.getwhole();
        denom = F1.getden();             //temp values for displaying fractions
        numer = F1.getnum();             //will be removed in final product
        sign = F1.getsign();             //same variables in option 2
    }
Hi
What your problem is, is that you are picking up the return char with your get line,

to get rid of this you should place the following after cin>>menuoption

 
    cin.ignore();


Hope this was helpful
Shredded
Thank you very much. That got me over a hurdle now I am on to the next...

Thanks again.
Topic archived. No new replies allowed.