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であると仮定する方法
それらを異なる数値として取得し、整数配列に格納する必要があります。
fscanfフォーマット指定子とともに使用し%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; }