How to use cin.get()

ch=cin.get(); or cin.get(ch)
which is correct. and what’s the use of this cin.get
can it be used only for reading a single character??

HI Raghav, the correct syntax to use cin.get is:

cin.get(ch) ;

The use of cin.get is to read whitespace charachters such as space or tab which cin >> cannot read.

get is used to read a whole string. just give the expected length as second parameter when calleng cin.get for ex:

cin.get(ch,30) ;

Hope this helps :slight_smile:

Hey Raghav,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

how can i mark the doubts as resolved?? there is no option

Hi,

there will be a Resolve button below your asked doubt as shown in the screenshot below.