+ 2
Scanf or getchar? C Language
Hi, im learning the language c but I get condfused because i dont understand Well the differences bettwen both of this functions. How do you reccomend to use??
5 ответов
+ 5
getchar() just gets a single character, whereas scanf() can get different types.
e.g.
int i;
scanf("%d", &i)
double r;
scanf("%f", &r);
https://stackoverflow.com/questions/3640604/c-getchar-vs-scanf
+ 1
and can i use a type of get but instead of one char to More???
+ 1
scanf() gets multiple characters (strings), and attempts to convert them into the correct type, see my previous answer.
Here's the documentation for scanf()
http://man7.org/linux/man-pages/man3/scanf.3.html
0
Use getchar when you want one character input. You can use scanf for variety of inputs but not get char.
0
Hi Kechu, you can use scanf() for printing one or more characters.