Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个看起来像这样的 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()这样的:
char
-
fscanf()
int existingarray[LEN],array3[LEN]; char array2[LEN]; //... fscanf(file,"%d %c %d", &existingarray[i], &array2[i], &array3[i]).