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...

Thanks was not sure what was needed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.