首页 > 代码库 > scanf ---------未完待续
scanf ---------未完待续
1.不可读入空格
#include<iostream>#include<stdio.h>using namespace std;int main(){ char c[50]; scanf("%s",c); printf("%s",c); return 0;}
2.可以读入空格
用字符 ^ 可以说明补集。把 ^ 字符放为扫描集的第一字符时,构成其它字符组成的命令的补集合,指示 scanf() 只接受未说明的其它字符。
#include<iostream>#include<stdio.h>using namespace std;int main(){ char c[50]; scanf("%[^\n]",c);// printf("%s",c); return 0;}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。