structers problems need to fix

i have done with this structure
but i have some syntax error idk how fix it
the errors start from line 22
idk what kind of error it is becuase the requirement is not a complete program ..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//write the defnetion of a structer type named movie to represnt a movie in video shop .
//the structers has the following members :
//Title (string) , Numberofcopies(int) , movietype(string).

//1- write one statment to declare FamilyMovie as a stuctere of type movie .
//2- write one statment to declare an array ListMovies of type movie of size 10.
//3- write statments to read data of 10 movies and store them in ListMovie .
//4- write staments to print data for all "comedy" movies in ListMovie .
//5- write statments to search and print titles of all movies with 0 numberofcopies in ListMovie.


struct movie
{
	string title;
	int numberofcopies;
	string movietype;
};
movie FamilyMovie;
movie ListMovies[10];
for(int i=0 ; i<10 ; i++)
cin >> ListMovies[i].title >>" ">> ListMovies[i].numberofcopies >>" ">> ListMovies[i].movietype;
for(int i=0 ; i<ListMovies[i].movietype ; i++)
cout << ListMovies[i].title="comedy"; 
cout << ListMovies[i].numberofcopies="comedy";
cout << ListMovies[i].movietype="comedy";

for(i=0 ; i<numberofcopies ; i++)
if(ListMovies[i] == title)
cout << ListMovies[i].title;
Last edited on
i<ListMovies[i].movietype

i is an int.

movietype is a string.

You are saying "keep going until the number i is less than the string movietype". This is nonsensical. It's meaningless.


You should also rewrite your code and put everything that's meant to be inside an if block in braces. Here, let me show you.
This is BAD.
1
2
3
4
for(int i=0 ; i<ListMovies[i].movietype ; i++)
cout << ListMovies[i].title="comedy"; 
cout << ListMovies[i].numberofcopies="comedy";
cout << ListMovies[i].movietype="comedy";


It is the same as this:
1
2
3
4
5
6
7
8
for(int i=0 ; i<ListMovies[i].movietype ; i++)
{
  cout << ListMovies[i].title="comedy"; 
}


cout << ListMovies[i].numberofcopies="comedy";
cout << ListMovies[i].movietype="comedy";


See how ONLY that first line is part of the if block? I suspect you did NOT mean that. I think you meant this:
1
2
3
4
5
6
for(int i=0 ; i<ListMovies[i].movietype ; i++)
{
  cout << ListMovies[i].title="comedy"; 
  cout << ListMovies[i].numberofcopies="comedy";
  cout << ListMovies[i].movietype="comedy";
}

Which is completely different.


None of your code above is inside any function. It just makes no sense. When is it supposed to run?
Last edited on
Topic archived. No new replies allowed.