Hello,

I have a program that uses getchar() and slightly confused and tried googling and it made it worse

cout << ">What is the expected letter <<"\n>";
        expectedLetter = getchar();
        putchar(expectedLetterl);
        string exletter = expectedleter + post;

cout <<">Do you wish to enter another letter (Y/y)/(N/n)\n>";
           repeatIn = getchar();
           putchar(repeatIn);
           if (repeatIn == 'y' || 'Y')
           {
               repeat = true;
           }

i have tried using

while(getchar()!='\n');

to clear the buffer , is there any other way / method? is there a simpler way to do this ?

Thanks

i have tried using

while(getchar()!='\n');

to clear the buffer , is there any other way / method? is there a simpler way to do this ?

Thanks

Can't get much simpler than that...

This question has already been answered. Start a new discussion instead.