Can anyone tell me the what's the use of getchar() and gets() ? In simple explanation please. I'm a beginner . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone tell me the what's the use of getchar() and gets() ? In simple explanation please. I'm a beginner .

1st Mar 2021, 2:18 PM
Adi
Adi - avatar
3 Answers
+ 3
..getchar reads one character like 'x' ...gets reads multiple characters like 'abc' You need this if you want to get input from a user. https://www.tutorialspoint.com/c_standard_library/c_function_getchar.htm https://www.tutorialspoint.com/c_standard_library/c_function_gets.htm#:~:text=The%20C%20library%20function%20char,is%20reached%2C%20whichever%20comes%20first.
1st Mar 2021, 2:23 PM
sneeze
sneeze - avatar
+ 4
Don't forget that 'gets' is deprecated because of security issues (so don't use it).
1st Mar 2021, 2:26 PM
Théophile
Théophile - avatar
+ 1
Ty very much 😊
1st Mar 2021, 2:32 PM
Adi
Adi - avatar