How To Clear The Input Buffer | C++ Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I love how you make each and every video stand on its own feet, in the sense that the viewer has to never refer to a previous video to get hold of the topic being taught. Thank you for going the extra mile making each tutorial self-reliant!

amkhrjee
Автор

Thank you so much, I love how you convert the science from a thing we should memorize to a thing we could understand so we can deal with in many cases thank you <3

mohamedtalal
Автор

The only person on youtube who explained this correctly

emreibrahim
Автор

the comments already express what I want to say, thank you for this!

OOGWAYnewcp
Автор

Thanks for this. On point, intelligent explanation.

tanmaygoyal
Автор

Dios mío! esto es poesía pura. GRACIAS.

leonardopantoja
Автор

Ma Sha Allah... Wonderful explanation... 💌💌💌

alizeeshan
Автор

That's really so useful, thank you !

Mohamed_Hisham
Автор

Awesome explanation as usual. Thank you, Sir. Please, make more videos on interesting topics in C++

saidrafili
Автор

You forget to mention to add the library <limits>.

MeuCanal
Автор

thank you ! i finished the program and the get line function worked only for one time and i thought i had to start all over again but hey it is all that buffer thing, so all i have to do is the ignore function just befor the get line to ensure that the buffer is empty right?

AMINE-ddqy
Автор

Great video Sir. Your channel really helps me a lot in learning programming especially c++. But I have one question sir. Do you have any resources on how I can deeply understand buffers in c++ and how it works?

yuwownly
Автор

Hello!!! Nice video sir explainning a difficult concept like clear the buffer, but I have a qusetion, I'm using Netbeans for windows, and when I use the cin.ignore(1, '\n'), my program can delete 1 skip even if I just put 1 for ignore the '\n'. I whant to know if thi is because we areusing differents IDE's or it's because something else.

alonsoperez
Автор

You can do this with string but not with char or int.

char msg;
cin>>msg;
cout<<msg<<endl;
cin.ignore(1, '\n');
cout<<"enter to exit";
cin.get();
return 0;


you ran the program
you wrote "Clear the input" and then pressed enter
output is "C"
input buffer has "lear the input/n"
cin.ignore command cleared the "l" because there is no /n at the begining.
cin.get got "e"
program quit
You couldn't see the output.

What if the user makes an unintended or undesired type of keystroke? So cin.ignore didn't help in this situation. Isn't there a command that will clear the entire input buffer smoothly?

emreozbek
Автор

There is another solution that's a bit easier. You can do the following instead:
number = _getch();
include the <conio.h> library.


But thanks for the info. I didn't know you could this it like this too.

lf
Автор

What happens when you leave the parenthesis empty? cin.ignore();

emreozbek
visit shbcf.ru