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.
假设数据为 123 134 2312 32131 2131231 211212
它应该将它们作为不同的数字并将它们存储在一个整数数组中。
您可以使用fscanfwith%d格式说明符从文本文件中读取连续的整数值。
fscanf
%d
int i = 0, cap = 10; int *a = malloc(cap * sizeof(int)); int n; while (scanf("%d", &n)) { if (i == cap) a = realloc(a, (cap *= 2) * sizeof(int)); a[i++] = n; }