# Thread: i'm a beginner and i wrote this program but its not working

1. ## i'm a beginner and i wrote this program but its not working

Code:
```/*This program gets the amount of movies a person has seen in a
year and asks them to rate each one*/

#include <stdio.h>
#include <string.h>

main()
{

int ctr, numMovies, rating, favRating, leastRating;
char movieName[40], favourite[40], least[40];

favRating = 0;
leastRating = 10;

do

{
//This part is if someone entered a 0 or a negative number

printf("How many movies have you seen this year?\n\n");
scanf (" %d", &numMovies);

if (numMovies < 1)
{
printf("No movies! How can you rank them?\n\nTry again\n\n");
}

}

while (numMovies < 1);

for (ctr = 1; ctr <= numMovies; ctr++)

{
//This part asks for name and the rating of the movie

printf("\nWhat was the name of the movie?");
printf("\n (1 word only and include capitals)\n");
scanf(" %s", movieName);
printf("\n\nOn a scale of 1 to 10, what would \nyou rate it?\n");
scanf(" %d", &rating);

while ( rating > 10) /*This part is if someone enters a number
that's not between 1 and 10*/
{
printf("That's not between 1 and 10!\n\n");
printf("Try again.\n\n");
scanf(" %d", &rating);
}

while ( rating < 0)

{

printf("That's not between 1 and 10!\n\n");
printf("Try again.\n\n");
scanf(" %d", &rating);
}

printf("\nEnter the name of the next movie\n\n\n");

/*This part calculates which movies
were the most hated and the most loved by the user*/

if ( rating > favRating)
{
strcpy(favourite, movieName);
favRating = rating;

}

if ( rating < leastRating)
{
strcpy(least, movieName);
leastRating = rating;
}

}

printf("\nYour Least Favourite Movie was %s.\n\n", least);

if(favourite != 'Inception') /*My favourite movie was Inception so
if they don't enter Inception this shows*/
{
printf("\nYour Favourite Movie was %s.\n\n", favourite);
}

else if(favourite == 'Inception') /*Here's where it's not working.
Everytime I put in Inception and
rated it 10 the other one would still show up
I don't know what's wrong*/
{
printf("\nYour Favourite Movie was %s.\nThat was my favourite movie too!\n\n", favourite);

}

return 0;
}```

2. > else if(favourite == 'Inception')
Use strcmp to compare strings.
For the same reason you used strcpy instead of assignment.

3. i dont understand

4. > strcpy(least, movieName);
When you did this, why didn't you try this wrong thing? least = movieName;

> if(favourite != 'Inception')
So to compare, use strcmp
like
strcmp(favourite,"Inception")
I'll leave you to rtfm to find out what strcmp returns when strings match.

5. on that strcmp trip.
Code:
```if ( strcmp("me", m) == 0 )
{
// if true
doSomething;
}
else
{
// if false
doSomethingElse
}```