The way being suppose the data is 123 134 2312 32131 2131231 211212
It should take them as different numbers and store them in an integer array .
The way being suppose the data is 123 134 2312 32131 2131231 211212
It should take them as different numbers and store them in an integer array .
You can use fscanf
with %d
format specifier to read successive integer values from a text file.
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;
}