+ 1

Cin.get()

what happens if we use int in cin.get() and whats the diffrence from using it for char?

14th Mar 2021, 6:41 PM
Sahaarr
Sahaarr - avatar
4 Réponses
+ 1
The people who coded that function designed it to be used for reading character array since it is the fundamental unit of data and it is efficient for memory. you can use atoi() function to convert an char array or string to integer easily. signature is get(char [25], int) if you use int instead of char. it will cause error i think.
14th Mar 2021, 7:01 PM
deleted
+ 1
AssasinStudent I see 🤔 thanks a lot🙏🏼
14th Mar 2021, 7:19 PM
Sahaarr
Sahaarr - avatar
0
AssasinStudent thank you! it doesn't cause error but it won't work with using enter to get out of program, do you know how can I solve it?
14th Mar 2021, 7:03 PM
Sahaarr
Sahaarr - avatar
0
I really don't know. Usually pressing enter have to stop the program. I just tested it on my machine it gives error when i use int. It may be depend on compiler. Unfortunately people are not good at designin programming languages. Always there is a bug in somewhere and they are complex to write and learn.
14th Mar 2021, 7:11 PM
deleted