If i want to read ‘PARTH’ using cin.get()…then i have to call it five times ??? cin.get() consider space as an element ???
what if i have an array of size 1000…but i only put 10 values in the array then, how will ‘ch’ becomes ‘\n’ ???
If i want to read ‘PARTH’ using cin.get()…then i have to call it five times ??? cin.get() consider space as an element ???
what if i have an array of size 1000…but i only put 10 values in the array then, how will ‘ch’ becomes ‘\n’ ???
hello @parth_tyagi
yeah cin.get read one character at a time, so u need to call it five times.
yes cin.get consider space as well.
it will not depend on array size, instead it will depend on how u give input in ur input box. if u give 10 entries and then rest input in next line then while reading \n will occur after first 10 character
what if size of array is 1000…and i give input “parth tyagi” only…then after ’ i ’ cin.get() function will read the array upto last index ??? (Nothing is written in next line)
…
no, it will depend what terminating condition u have given in ur loop.
Also can explain how to use cin.get() function with example ??? I think i have a doubt in that part.
…
it reads one charaacter at a time, thats the only funtionality it has.
when ch= cin.get(); … then i have to give input right?? But when enter the loop and update ch again with cin.get()…then what happens??? When i call cin.get() fuction and type ‘parth’ and then cout array…will it print ‘P’ only???
…
no first u will get P then a then r then t so on
check now->
doubt cleared. Thanks
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.