码迷,mamicode.com
首页 > 其他好文 > 详细

scanf ---------未完待续

时间:2014-08-13 17:36:06      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:blog   http   os   io   ar   2014   log   size   

1.不可读入空格

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	char c[50];
	scanf("%s",c);
	printf("%s",c);
	return 0;
}

bubuko.com,布布扣

2.可以读入空格

用字符 ^ 可以说明补集。把 ^ 字符放为扫描集的第一字符时,构成其它字符组成的命令的补集合,指示 scanf() 只接受未说明的其它字符。

 

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	char c[50];
	scanf("%[^\n]",c);//
	printf("%s",c);
	return 0;
}

bubuko.com,布布扣

 

scanf ---------未完待续,布布扣,bubuko.com

scanf ---------未完待续

标签:blog   http   os   io   ar   2014   log   size   

原文地址:http://www.cnblogs.com/bofengyu/p/3910184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!