免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: greatho1507
打印 上一主题 下一主题

fscanf()读取文件中的字符串是以什么为分界的 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2008-08-13 18:45 |只看该作者

回复 #10 qliu00 的帖子

胡说八道!
首先是\0不是/0
其次,hello和word中间没有\0
再次,见sscanf的manpage
       s      Matches  a  sequence  of  non-white-space  characters;  the next
              pointer must be a pointer to character array that is long enough
              to  hold  the  input sequence and the terminating null character
              ('\0'), which is added automatically.  The input string stops at
              white  space  or  at  the  maximum field width, whichever occurs
              first.

论坛徽章:
0
12 [报告]
发表于 2008-08-14 09:24 |只看该作者
我问的是fscanf,不是sscanf。。。。。。。。。。

论坛徽章:
0
13 [报告]
发表于 2008-08-14 09:31 |只看该作者
原帖由 madoldman 于 2008-8-13 18:45 发表
胡说八道!
首先是\0不是/0
其次,hello和word中间没有\0
再次,见sscanf的manpage
       s      Matches  a  sequence  of  non-white-space  characters;  the next
              pointer must be a p ...



要是hello和word中间有\0呢,你学了C语言么,字符串以什么结束?

不知道就别说

论坛徽章:
0
14 [报告]
发表于 2008-08-14 09:37 |只看该作者
hello world 中间没有'\0',我直接用"hello world" hello world 是一个字符串而不是两个,中间有个空格符号.......

论坛徽章:
0
15 [报告]
发表于 2008-08-14 09:39 |只看该作者
中间有个空格符号.我知道

你去查下C语言最基本的教程,看看有没有

论坛徽章:
0
16 [报告]
发表于 2008-08-14 09:45 |只看该作者
要是hello和word中间有\0,
printf如何输出有空格的字符串?

论坛徽章:
0
17 [报告]
发表于 2008-08-14 10:09 |只看该作者
原帖由 greatho1507 于 2008-8-14 09:45 发表
要是hello和word中间有\0,
printf如何输出有空格的字符串?

你可以多写一个printf()

论坛徽章:
0
18 [报告]
发表于 2008-08-14 10:11 |只看该作者
..........
我直接printf("hello world")是可以直接输出hello world的吧?

论坛徽章:
0
19 [报告]
发表于 2008-08-14 10:21 |只看该作者
直接printf("hello world")可以直接输出hello world

论坛徽章:
0
20 [报告]
发表于 2008-08-14 10:23 |只看该作者
你们在讨论什么?怎么可以输出"hello world"??
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP