Troubles with array and menu for a library

Hi,

I've been troubleshooting this for hours, and I really am confused as to what I am doing wrong.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

const int ARRAY_SIZE = 200;
string movieTitle [ARRAY_SIZE];
string movies;

int loadData (string pathname);
int getTitle (string movies);
void showAll (int count);


int main()
{
	loadData("movies.txt");
	char userInput;
	string movieTitle[ARRAY_SIZE];
	int count = getTitle(movies);
	
	bool endOfProgram = false;
	while (endOfProgram ==false)
	{
		cout << "1. Read in Collection" << endl;
		cout << "2. Print Collection" << endl;
		cout << "3. Add a Movie to the Collection" << endl;
		cout << "4. Write out Collection" << endl;
		cout << "5. Quit the Program" <<endl;
		cin >> userInput;
		
		switch(userInput)
		{
			case('1'): 
			{
				loadData(movies.txt);
				break;	
			}
			
			case('2'):
			{
				showAll(loadData(movies.txt));
				break;
			}
			case('3'):
			{
				cout <<"Add Movies to the Collection. Press (q) to quit"<< endl;
				cin >> movieTitle;
			}
			case('4'):
			{
				cout <<"Write out Collection" << endl;
				outfile.open ("movies.txt");
				if(!outfile.is.open())
				{
					cout <<"Cannot open movies.txt" << endl;
					return -1;
				}
				
				outfile.close();
			}
			case('5'):
			{
				endOfProgram=true;
				cout << "Have a nice day" <<endl;
				break;
			}
		}
int loadData (string pathname)
{
	int count = 0;
	ifstream inFile;
	inFile.open(pathname.c_str());
	
	if (!inFile)
		return -1;
	else
	{
		while(!inFile.eof())
		{
			getline(inFile, movieTitle[count]);
			count++
		}
	}
	return count;
}
void showAll (int count)
{
	cout << "\n";
	for (int i=0; i< count; i++)
	{
		cout << movieTitle[i] << endl;
	}
	cout << "\n";
}

int getTitle (string movies[]);
{
	string movieTitle
	int count = 0;
	
	while(true)
	{
		cout <<"Enter Movie Titles (Type 'q' to quit)" <<endl;
		cin >> movies;
		if (movies == "q")
		{
			break;
		}
		movies [count] = movies;
		count++;
	}
	
	return count;
}
void printMovies(const string movies [], int count)
{
	for(int i=0; i<count;i++
	{
		cout <<movies[i] <<endl;
	}
}


These are the error messages I am receiving:

36 21 C:\Users\MyName\Documents\Class\Project\project5c++.cpp [Error] 'std::string' has no member named 'txt'
42 29 C:\Users\MyName\Documents\Class\Project\project5c++.cpp [Error] 'std::string' has no member named 'txt'
48 9 C:\Users\MyName\Documents\Class\Project\project5c++.cpp [Error] no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'std::string [200] {aka std::basic_string<char> [200]}')


I'd sincerely appreciate any and all help, or just a point in the right direction. Thanks so much.
The name of the variable is movies not movies.txt. With movies.txt you are trying to access a member of the string named txt which does not exists. You might want the string "movies.txt". That's different.

Something like this movies [count] = movies; does not make sense. Either movies is an array or not. Both is not possible. In your case movies is not an array.
Topic archived. No new replies allowed.