So I want to read user input array of UNKNOWN number of values ,eg: 1.0 3.0 -2.0.... etc, naturally I did scanf("%s", array) first and realized that it would only read until first space, and then I attempted the following:
#include <stdio.h>
int main()
{
printf("enter array: ");
char str[100];
fgets(str, 100, stdin);
printf("%s", str);
return 0;
}
That itself works, however when I incorporated it into the rest of my code it does not work it just skips the input of the array
#include <stdio.h>
int main()
{
float a, b;
int t;
printf("A: ");
scanf("%f",&a);
printf("B: ");
scanf("%f",&b);
printf("T: ");
scanf("%d",&t);
printf("enter array: ");
char str[100];
fgets(str, 100, stdin);
printf("%s", str);
return 0;
}
What am I doing wrong please help