scanf与gets区别

scanf( )函数和gets( )函数都可用于输入字符串,但在功能上有区别。若想从键盘上输入字符串"hi hello",则应该使用__gets__函数。 gets可以接收空格;而scanf遇到空格、回车和Tab键都会认为输入结束,所有它不能接收空格。 char string[15]; gets(string); /*遇到回车认为输入结束*/ scanf("%s",string); /*遇到空格认为输入结束*/ 所以在输入的字符串中包含空格时,应该使用gets输入。 ...
2012-10-27 11:10 | 阅读 1281 次 | 评论 2 条

scanf, scanf_I, wscanf, wscanf_I

Read formatted data from the standard input stream. These are versions of scanf, _scanf_l, wscanf, _wscanf_l with security enhancements as described in Security Enhancements in the CRT. ...
2012-10-27 10:45 | 阅读 1604 次 | 评论 0 条
浏览18288次
文章归档