Fill in an array from a single formatted keyboard line in C
How can I fill in a double or int array from a single, arbitrarily long,
formatted (e.g. space delimited) keyboard line?
For instance:
Enter the elements of the array: 2 32 12.2 4 5 ...
should result in => array[0] = 2 => array[1] = 32 etc.
I know that I can use scanf as follows, but that does not solve my
problem, since each element should be entered one by one.
/* Input data from keyboard into array */
for (count = 1; count < 13; count++)
{
printf("Enter element : %d: ", count);
scanf("%f", &array[count]);
}
Thanks.
No comments:
Post a Comment