将数字从文件填充到数组 [英] filling numbers from a file to an array

查看:70
本文介绍了将数字从文件填充到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii,

i我在c工作,我的问题是我创建了一个包含数字的文件,我想将这些数字存储在一个数组中。请指导我如何去做这是我写的代码的一部分,它显示了一百个数字,但所有值都相同,它显示277 866 100次。


while((ch = fgetc(fp) != NULL)

{

for(i = 0; i< 10; i ++)

for(j = 0; j< 10 ; j ++)

{

image [i] [j] = ch;

printf("%d%d",image [ i] [j]);

}

解决方案

将读取放入循环中?

展开 | 选择 | Wrap | 行号



将读取放入循环中?

展开 | 选择 | Wrap | 行号


我在c工作,我已创建一个包含100个数字的文件。我希望将这些数字存储在一个数组中,如[10] [10]。如何做到这一点。请给出代码做tjis.i已经在屏幕上显示了数字但是之后我想要将数字存储在数组中。请帮助其紧急吨。

hii,
i am working in c and my problem is that i have created a file which contains numbers,i want to store these numbers in an array.,please guide me how to go about it this is the part of code that i have written ,it is showing hundred numbers but all values are same and it shows 277 866 100 times.

while((ch=fgetc(fp)!=NULL)
{
for(i=0;i<10;i++)
for(j=0;j<10;j++)
{
image[i][j]=ch;
printf("%d %d",image[i][j]);
}

解决方案

put the read in the loops?

Expand|Select|Wrap|Line Numbers


put the read in the loops?

Expand|Select|Wrap|Line Numbers


i am working in c and i have created a file which contains 100 numbers.i want to store these numbers in an array like a[10][10].how to do this.please give the code to do tjis.i have displayed the numbers on the screen but after that i want to store the numbers in an array.please help its urgent.


这篇关于将数字从文件填充到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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