使用fscanf从文件读取字符 [英] Reading characters from a File with fscanf

查看:905
本文介绍了使用fscanf从文件读取字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,使用fscanf函数:(
我需要reed一个字符序列的文件像abcd(字符由空格分隔)。

I have a problem, using fscanf function :( I need to reed a sequence of characters from file like "a b c d" (characters are separated by space).

但它不工作:(
我怎么读他们?(

but it doesn't works :( how I have to read them? (

我试图打印它,结果是不正确的。我想,这是因为空格,我真的不知道为什么它不工作。

I tried to print it and the result is uncorrect. I think, it's because of spaces. I really don't know why it doesn't work.

请告诉我,数组访问有什么问题?

Tell me please, what is wrong with array access?

推荐答案

在%c =>

while (fscanf(pFile," %c", &alpArr[i++]) == 1); 


b $ b

它应该工作。

It should work.

这篇关于使用fscanf从文件读取字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆