大家好,我在这里阅读了很多答案,但对我没有任何帮助。
我有此代码:
typedef struct{
char nome[100];
double tempo;
int difficult;
}Recipe;
Recipe* array;
/*
code
*/
array = malloc(sizeof(Recipe)*num_recipes);
for(int i=0; i<num_recipes; i++){
printf("\nType the recipe name: ");
fgets(array[i].name, sizeof(array[i].name), stdin);
printf("Type how much time you spent for it: ");
scanf("%lf", &array[i].time);
printf("Type how much difficult it is: ");
scanf("%d", &array[i].difficult);
}
/*
code
*/
free(array);
问题在于它不等待配方名称的键盘输入与此输出:
输入配方名称:输入花费的时间:
我该如何解决?