scanf("%3c", &c);
My girlfriend CC asked me a question about C programming language today, “What does scanf("%mc", &c)
mean?” When I heard this question, I immediately thought that it should resemble printf("%mc", c)
, which means writing character c
in m-chars width to standard output. Therefore, scanf("%mc", &c)
should mean reading character c
in m-chars width from standard input and I wrote a simple test file as following:
# include<stdio.h>
int main(){
char c;
scanf("%3c", &c);
printf("%c\n", c);
return <