我有一个看起来像这样的 txt 文件
63001230 3 10
63001234 8 3
63000176 8 6
63001432 - 0
我已经存储了前 8 位数字。现在,我想将第二列 (3 8 8 -) 存储在一个数组中,将第三列 (10 3 6 0) 存储在另一个数组中。
我用它来做吗
fscanf(file,"%d %d %d", existingarray[i], array2[i], array3[i])
最佳答案
第二个数组必须是char
才能读取-
。
您还必须像这样将数组元素的地址传递给 fscanf()
:
int existingarray[LEN],array3[LEN];
char array2[LEN];
//...
fscanf(file,"%d %c %d", &existingarray[i], &array2[i], &array3[i]).
关于c - 扫描相似的数字并将它们放在不同的数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15731803/