0

Doubt

Difference between scanf("%c",&a) and a=getchar()

10th Nov 2020, 8:47 AM
S.Brindha
S.Brindha  - avatar
1 Réponse
+ 1
getchar can literally be read as "get a character" (singular) meaning it just grabs one character at a time. scanf will take the first occurence of a char array (no spaces) and assign it to a memory address for later (what '&' is for) Basically, getchar() for 1 character, scanf for a single word w/ no spaces, and fgets for grabbing sentences. (you'll learn about that one very soon!)
10th Nov 2020, 9:28 AM
Slick
Slick - avatar