+ 2
I am using gets() in 'for' loop, but it does not take the user's input. Any solution, thanks in advance.
3 odpowiedzi
+ 3
Hi! I played around with your code. Please take a look. Technical details were well explained by Martin Taylor.
https://code.sololearn.com/c3gz4mYFdG0Z/?ref=app
+ 3
It will be great if you share your code
+ 1
#include<stdio.h>
#include<string.h>
main()
{
int i,numMovies,rating,favRating,leastRating;
char movieName[40];
char fav[40],least[40];
favRating=0;
leastRating=10;
do
{
printf("how many movies did you watch in last one year\n");
scanf("%d",&numMovies);
if(numMovies<1)
{
printf("you didn't watch any movies how you rate them\n");
printf("try again\n");
}
}while(numMovies<1);
for(i=0;i<numMovies;i++)
{
puts("enter the movie name");
gets(movieName);
printf("rate this movie\n");
scanf("%d",&rating);
if(rating<favRating)
{
strcpy(fav,movieName);
favRating=rating;
}
if(rating>leastRating)
{
strcpy(least,movieName);
leastRating=rating;
}
}
printf("your favourite movie is %s",fav);
printf("your least favourite movie is %s,least");
return (0);
}