是什么在scanf中的空间是什么意思? [英] What does space in scanf mean?
本文介绍了是什么在scanf中的空间是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的#include<&stdio.h中GT;
INT主(INT ARGC,CHAR *的argv []){
焦炭℃;
scanf函数(%C,和C);
的printf(%C \\ n,C);
返回0;
}[根@测试]#./scanf
一个
一个[根@测试]#./scanf
H
H
它似乎总是相匹配的空间是否存在,为什么?
解决方案
空白(如空格,制表符或换行符)格式字符串匹配的白色空间,包括无,输入任何金额。
块引用>http://www.manpagez.com/man/3/scanf/
#include <stdio.h> int main(int argc, char* argv[]) { char c; scanf(" %c", &c); printf("%c\n", c); return 0; } [root@test]# ./scanf a a [root@test]# ./scanf h h
It seems always matching whether space exists,why?
解决方案White space (such as blanks, tabs, or newlines) in the format string match any amount of white space, including none, in the input.
http://www.manpagez.com/man/3/scanf/
这篇关于是什么在scanf中的空间是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文