Pointer Array and Files

I have an assignment where I am to allocate an array of 100 pointers, all pointing to a struct called Movie. I am to also store the movie name and rating. This program compiles but I can't get it to save the values to a file. Please help me

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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
 #include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

#define MAX_MOVIES 100

using namespace std;

enum {ADD = 1,PRINT, SEARCH, EXIT};

struct Movie
{
	string nameOfMovie;
	int scoreOfMovie;
};

void LoadFile(Movie* moviePtr[], int& count);
void ReadChoice (int& choice);
void DisplayMenu ();
void ProcessChoice (Movie* movie[], int& count, int choice);
void CheckInput (string prompt, int& num);
void AddMovie (Movie movie[], int& count);
bool ScoreValid (int score);
void Print (Movie const moviePtr[], int count);
void SearchMovie (Movie const movie[], int count);
string Tomato (int score);
void SaveFile(Movie* movie[], int count);
void DeletePtr(Movie* moviePtr[], int count);
void PrintLine (int size, char ch);

// Function: main
// Purpose: To add, search, and store names of movies with their rating and assigning them a FRESH or ROTTEN tag based on rating. 
// Input: movies, count, choice
// Output: movies
// In Param: none
// Out Param: none
// Return: 0
// Function Called: LoadFile, ReadChoice, ProcessChoice, SaveFile
// Error Messages: none
int main ()
{
	Movie *moviePtr[MAX_MOVIES] = {0};
	*moviePtr = new Movie[MAX_MOVIES];
	int count = 0;
	int choice;

	LoadFile(moviePtr, count);
	ReadChoice(choice);
	if (*moviePtr != 0)
	while(choice != EXIT)
	{
		ProcessChoice(moviePtr, count, choice);
		ReadChoice(choice); 
	}
	SaveFile(moviePtr, count);
	DeletePtr(moviePtr, count);
	
	return 0;
}

// Function: LoadFile
// Purpose: To load, a pre-existing file and to create a file if it does not exist.
// Input: infile
// Output: none
// In Param: movie, count
// Out Param: none
// Return: none
// Function Called: PrintLine
// Error Messages: none
void LoadFile(Movie* moviePtr[], int& count)
{
	ifstream infile;
	
	infile.open("tomatoes.txt");
	if(infile.is_open())
	{
		PrintLine(40, '=');
		cout << "LOADING DATA FROM FILE..." <<endl;
		while (!infile.eof())
		{	
			moviePtr[count] = new Movie;
			getline(infile, moviePtr[count]->nameOfMovie,'|');
			infile >> moviePtr[count]->scoreOfMovie;
			infile.ignore();
			if(!infile.eof())
			{
				count++;
			}
		}
	}
}

// Function: ReadChoice
// Purpose: To accept an menu choice from the user.
// Input: none
// Output: none
// In Param: choice
// Out Param: choice
// Return: none
// Function Called: PrintLine
// Error Messages: none
void ReadChoice (int& choice)
{
	do{
		DisplayMenu ();
		CheckInput ("Enter 1-4 : ", choice);
		PrintLine(40, '=');
	}while (choice < ADD || choice > EXIT);
}

// Function: DisplayChoice
// Purpose: To display a menu to the monitor. 
// Input: none
// Output: none
// In Param: none
// Out Param: none
// Return: none
// Function Called: PrintLine
// Error Messages: none
void DisplayMenu()
{
	PrintLine(40, '=');
	cout << "MENU" << endl;
	PrintLine(40, '-');
	cout << ADD << "." << "Add Movie" << endl
		 << PRINT << "." << "Print All" << endl
		 << SEARCH << "." << "Search Movie" << endl
		 << EXIT << "." << "Exit" << endl;
	PrintLine(40, '-');
}

// Function: ProcessChoice
// Purpose: To either add a movie or search the name of a movie based on user input.
// Input: none
// Output: none
// In Param: movie, count, choice
// Out Param: movie, count
// Return: none
// Function Called: AddMovie, SearchMovie
// Error Messages: none
void ProcessChoice (Movie* movie[], int& count, int choice)
{
	switch (choice)
	{
	case ADD:
		AddMovie(movie[count], count);
		break;
	case PRINT:
		Print(movie[count], count);
		break;
	case SEARCH:
		SearchMovie(movie[count], count);
		break;
	}
}

// Function: CheckInput
// Purpose: To stop crashes when program expects numbers but user inputs char or string.
// Input: valid
// Output: none
// In Param: prompt, num
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: Invalid Input
void CheckInput (string prompt, int& num)
{
	bool valid;

	do{
		cout << prompt;
		cin >> num;
		if (cin.fail())
		{
			cin.clear();
			cout << "Invalid Input!" << endl;
			valid = false;
		}
		else
		{
			valid = true;
		}
		cin.ignore(1000,'\n');
	} while (!valid);
}

// Function: AddMovie
// Purpose: To add a new movie and give it a rating. 
// Input: none
// Output: none
// In Param: movie, count
// Out Param: movie, count
// Return: none
// Function Called: PrintLine
// Error Messages: LIST IS FULL
void AddMovie (Movie movie[], int& count) // made movie an array
{
	if(count < MAX_MOVIES)
	{
		cout << "ADD MOVIE" << endl;
		PrintLine(40, '-');
		cout << "Title: ";
		getline(cin, movie[count].nameOfMovie);
		do{
			CheckInput("Rating: ",movie[count].scoreOfMovie);
		} while (!ScoreValid (movie[count].scoreOfMovie));
	}
	else 
		cout << "LIST IS FULL!" << endl; 
}

// Function: ScoreValid
// Purpose: To validate the rating assigned by user.
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: true or false
// Function Called: none
// Error Messages: none
bool ScoreValid (int score)
{
	if (score < 0 || score > 100)
	{
		cout << "Rating must be between 0 and 100" << endl;
		return false;
	}
	else
		return true;
}

// Function: Print
// Purpose: To print out all movies stored in the array
// Input: none
// Output: none
// In Param: moviePtr, count
// Out Param: none
// Return: none
// Function Called: Printline
// Error Messages: none
void Print (Movie const moviePtr[], int count)
{
	cout << "Movies:" << endl;
	PrintLine(20, '=');
	cout << "Title" << setw(16) << "Rating" << endl;
	PrintLine(20,'-');
	for (int i = 0; i < count; i++)
	{
		cout << setw(18) << left << moviePtr[i].nameOfMovie << right << moviePtr[i].scoreOfMovie << endl;
	}
	PrintLine(20,'-');
}

// Function: SearchMovie
// Purpose: To search through an array of previously added movies.
// Input: searchName, found
// Output: none
// In Param: movie, count
// Out Param: movie, count
// Return: true or false
// Function Called: PrintLine, Tomato
// Error Messages: NOT FOUND
void SearchMovie (Movie const movie[], int count)
{
	string searchName;
	bool found = false; 
	cout <<"SEARCH MOVIE" << endl; 
	PrintLine(40, '-');
	cout << "Enter Title: ";
	getline(cin, searchName);
	for(int i = 0; i < count && !found; i++)
	{
		if (searchName == movie[i].nameOfMovie)
		{
			cout << setw(30) << left << movie[i].nameOfMovie << right 
				 << movie[i].scoreOfMovie <<"% " << Tomato(movie[i].scoreOfMovie) << endl;
			found = true;
		}

	}
	if (!found)
	{
		cout << "NOT FOUND" << endl;
	}
}

// Function: Tomato
// Purpose: To assign a FRESH or ROTTEN tag to a movie based on rating.
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: ROTTEN and FRESH
// Function Called: none
// Error Messages: none
string Tomato (int score)
{
	if (score <= 59)
	{
		return "ROTTEN";
	}
	else 
		return "FRESH";
}

// Function: SaveFile
// Purpose: To save any changes to the file 
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void SaveFile( Movie* movie[], int count)
{
	ofstream outfile;
	outfile.open("tomatoes.txt");
	for (int i = 0; i < count; i++)
	{
		outfile << movie[i]->nameOfMovie <<'|' << movie[i]->scoreOfMovie << endl; 
	}
	cout << "SAVED TO FILE." << endl; 
}

// Function: DeletePtr
// Purpose: To free space allocated by the pointer array after the program ends.
// Input: none
// Output: none
// In Param: moviePtr, count
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void DeletePtr(Movie* moviePtr[], int count)
{
	for(int i = 0; i < count; i++)
	{
		delete moviePtr[i];
		moviePtr[i] = 0;
	}
	
}

// Function: PrintLine
// Purpose: To format the output
// Input: none
// Output: none
// In Param: size, ch
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void PrintLine (int size, char ch)
{
	cout << setw(size) << setfill(ch) << ""
         << setfill(' ') << endl;
}
You have a few issues in your SaveFile function.

1. You never check to make sure tomatoes.txt actually successfully opened for writing. I see you do this in your LoadFile function, but not in SaveFile.

2. You never flush outfile's buffer*. Doing so is as simple as calling close() when you're done with outfile.

*std::ofstreams maintain a buffer that stores data that they're supposed to write to the file. Then, the buffer is written when close() is called (or when it's about to overflow or you flush it).

-Albatross
Last edited on
Following your recommendation, tomatoes.txt gets created but nothing gets written to it. I thought files automatically close after the function ends.

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
void LoadFile(Movie* moviePtr[], int& count)
{
	ifstream infile;
	
	infile.open("tomatoes.txt");
	if(infile.is_open())
	{
		PrintLine(40, '=');
		cout << "LOADING DATA FROM FILE..." <<endl;
		while (!infile.eof())
		{	
			moviePtr[count] = new Movie;
			getline(infile, moviePtr[count]->nameOfMovie,'|');
			infile >> moviePtr[count]->scoreOfMovie;
			infile.ignore();
			if(!infile.eof())
			{
				count++;
			}
		}
	}
}


void SaveFile( Movie* movie[], int count)
{
	ofstream outfile;
	outfile.open("tomatoes.txt");
	
	if(outfile.is_open())
	{
		for (int i = 0; i < count; i++)
		{
			outfile << movie[i]->nameOfMovie <<'|' << movie[i]->scoreOfMovie << endl; 
		}
		outfile.close();
		cout << "SAVED TO FILE." << endl;
	}
}
Last edited on
I opened the tomatoes.txt file and wrote movie|100 as a test value. My program says it loaded but when I select print all it does not show the test movie I wrote in the txt.
See... something confuses me about your code. Specifically about moviePtr. What would you like moviePtr to be? A pointer? Or an array of pointers?

-Albatross
I am creating an array of 100 pointers that will point to datatypes in in the struct Movie.
I'm unsure as to whether it is due to the way the array of pointers gets created or whether it is due to a fault by the Add, Print, and Search functions.
A combination of both, actually.

While you are trying to make an array of pointers, you make the first element point to an array of movies when you initialize it (line 44), and the rest point to nothing meaningful.

Then, when you're using your add, print, and search functions, you're dereferencing an element of that array (a pointer) and passing that as an argument to your functions, which then treat it an array of objects.

-Albatross
I changed line 44 to this. How should I change the parameters on my Add, Print, and Search functions to stay consistent. Sorry my code is confusing. I am so thankful for your help.

 
*moviePtr = new Movie;

...try again. :/

Once you have your array of pointers (which... why are you using an array of pointers instead of a simple array is a good question, but a forgivable detail at this stage), you have an array of pointers that point to nothing. What you're doing there is setting the first element of that array to a Movie.

You have a choice.
A: Use a while loop and make each pointer point to a newed Movie. Then, remove the bit of code that news Movies as needed in your LoadFile function.
B: Don't initialize any of the pointers to anything and make new Movies as needed, using count as the value of the next "free" array element. Do something in AddMovie that's similar to what you do in LoadFile.

As for those three functions, that depends.
For Search and Print: You'll need to pass the pointer to the array and count, because the functions need access to the whole array and need to know where the last valid element is (at count - 1).
For Add: You can get away with passing a reference to one of the elements of the array and nothing else. Add only needs to know where it can put the data for the new movie. Of course, you can always pass the pointer to the array and count as well and have Add figure out where to put it.

Also, you should get into the habit of delete-ing what you new. Don't trust the OS to always clean up after you.

-Albatross
Last edited on
Yea its an assignment, this would not be my preferred method. I'll do my best to implement your ideas into actually code. I have been absolutely troubled by this assignment. I'll be sure to comment if I get it to work.
I got it to work! I'll post the complete code here for reference. Thank you so much Albatross!
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

#define MAX_MOVIES 100

using namespace std;

enum {ADD = 1,PRINT, SEARCH, EXIT};

struct Movie
{
	string nameOfMovie;
	int scoreOfMovie;
};

void LoadFile(Movie* moviePtr[], int& count);
void ReadChoice (int& choice);
void DisplayMenu ();
void ProcessChoice (Movie *movie[], int& count, int choice);
void CheckInput (string prompt, int& num);
void AddMovie (Movie *movie[], int& count);
bool ScoreValid (int score);
void Print (Movie* const moviePtr[], int count);
void SearchMovie (Movie* const movie[], int count);
string Tomato (int score);
void SaveFile(Movie* movie[], int count);
void DeletePtr(Movie* moviePtr[], int count);
void PrintLine (int size, char ch);

// Function: main
// Purpose: To add, search, and store names of movies with their rating and assigning them a FRESH or ROTTEN tag based on rating. 
// Input: movies, count, choice
// Output: movies
// In Param: none
// Out Param: none
// Return: 0
// Function Called: LoadFile, ReadChoice, ProcessChoice, SaveFile
// Error Messages: none
int main ()
{
	Movie *moviePtr[MAX_MOVIES] = {0};

	int count = 0;
	int choice;

	LoadFile(moviePtr, count);
	ReadChoice(choice);
	while(choice != EXIT)
		{
			ProcessChoice(moviePtr, count, choice);
			ReadChoice(choice);
		}
		SaveFile(moviePtr, count);
		DeletePtr(moviePtr, count);
	
	
	return 0;
}

// Function: LoadFile
// Purpose: To load, a pre-existing file and to create a file if it does not exist.
// Input: infile
// Output: none
// In Param: movie, count
// Out Param: none
// Return: none
// Function Called: PrintLine
// Error Messages: none
void LoadFile(Movie* moviePtr[], int& count)
{
	ifstream infile;

	infile.open("tomatoes.txt");
	if(infile.is_open())
	{
		PrintLine(40, '=');
		cout << "LOADING DATA FROM FILE..." <<endl;
		while (!infile.eof())
		{	
			moviePtr[count] = new Movie;
			getline(infile, moviePtr[count]->nameOfMovie,'|');
			infile >> moviePtr[count]->scoreOfMovie;
			infile.ignore();
			if(!infile.eof())
			{
				count++;
			}
		}
	}
}

// Function: ReadChoice
// Purpose: To accept an menu choice from the user.
// Input: none
// Output: none
// In Param: choice
// Out Param: choice
// Return: none
// Function Called: PrintLine
// Error Messages: none
void ReadChoice (int& choice)
{
	do{
		DisplayMenu ();
		CheckInput ("Enter 1-4 : ", choice);
		PrintLine(40, '=');
	}while (choice < ADD || choice > EXIT);
}

// Function: DisplayChoice
// Purpose: To display a menu to the monitor. 
// Input: none
// Output: none
// In Param: none
// Out Param: none
// Return: none
// Function Called: PrintLine
// Error Messages: none
void DisplayMenu()
{
	PrintLine(40, '=');
	cout << "MENU" << endl;
	PrintLine(40, '-');
	cout << ADD << "." << "Add Movie" << endl
		 << PRINT << "." << "Print All" << endl
		 << SEARCH << "." << "Search Movie" << endl
		 << EXIT << "." << "Exit" << endl;
	PrintLine(40, '-');
}

// Function: ProcessChoice
// Purpose: To either add a movie or search the name of a movie based on user input.
// Input: none
// Output: none
// In Param: movie, count, choice
// Out Param: movie, count
// Return: none
// Function Called: AddMovie, SearchMovie
// Error Messages: none
void ProcessChoice (Movie* movie[], int& count, int choice)
{
	switch (choice)
	{
	case ADD:
		AddMovie(movie, count);
		break;
	case PRINT:
		Print(movie, count);
		break;
	case SEARCH:
		SearchMovie(movie, count);
		break;
	}
}

// Function: CheckInput
// Purpose: To stop crashes when program expects numbers but user inputs char or string.
// Input: valid
// Output: none
// In Param: prompt, num
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: Invalid Input
void CheckInput (string prompt, int& num)
{
	bool valid;

	do{
		cout << prompt;
		cin >> num;
		if (cin.fail())
		{
			cin.clear();
			cout << "Invalid Input!" << endl;
			valid = false;
		}
		else
		{
			valid = true;
		}
		cin.ignore(1000,'\n');
	} while (!valid);
}

// Function: AddMovie
// Purpose: To add a new movie and give it a rating. 
// Input: none
// Output: none
// In Param: movie, count
// Out Param: movie, count
// Return: none
// Function Called: PrintLine
// Error Messages: LIST IS FULL
void AddMovie (Movie *movie[], int& count) 
{
	if(count < MAX_MOVIES)
	{
		movie[count] = new Movie;
		cout << "ADD MOVIE" << endl;
		PrintLine(40, '-');
		cout << "Title: ";
		getline(cin, movie[count]->nameOfMovie);
		do{
			CheckInput("Rating: ",movie[count]->scoreOfMovie);
		} while (!ScoreValid (movie[count]->scoreOfMovie));
		count++;
	}
	else 
		cout << "LIST IS FULL!" << endl; 
}

// Function: ScoreValid
// Purpose: To validate the rating assigned by user.
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: true or false
// Function Called: none
// Error Messages: none
bool ScoreValid (int score)
{
	if (score < 0 || score > 100)
	{
		cout << "Rating must be between 0 and 100" << endl;
		return false;
	}
	else
		return true;
}

// Function: Print
// Purpose: To print out all movies stored in the array
// Input: none
// Output: none
// In Param: moviePtr, count
// Out Param: none
// Return: none
// Function Called: Printline
// Error Messages: none
void Print ( Movie* const moviePtr[], int count)
{
	cout << "Movie List:" << endl;
	PrintLine(40, '=');
	cout << "Title" << setw(35) << "Rating" << endl;
	PrintLine(40,'-');
	for (int i = 0; i < count; i++)
	{
		cout << setw(29) << left << moviePtr[i]->nameOfMovie 
			<< setw(3) << right << moviePtr[i]->scoreOfMovie <<"% " 
			 << setw(8) << left << Tomato(moviePtr[i]->scoreOfMovie) << endl;
	}
	PrintLine(40,'-');
}

// Function: SearchMovie
// Purpose: To search through an array of previously added movies.
// Input: searchName, found
// Output: none
// In Param: movie, count
// Out Param: movie, count
// Return: true or false
// Function Called: PrintLine, Tomato
// Error Messages: NOT FOUND
void SearchMovie ( Movie* const movie[], int count)
{
	string searchName;
	bool found = false; 
	cout <<"SEARCH MOVIE" << endl; 
	PrintLine(40, '-');
	cout << "Enter Title: ";
	getline(cin, searchName);
	for(int i = 0; i < count && !found; i++)
	{
		if (searchName == movie[i]->nameOfMovie)
		{
			cout << setw(31) << left << movie[i]->nameOfMovie << right 
				 << movie[i]->scoreOfMovie <<"% " << Tomato(movie[i]->scoreOfMovie) << endl;
			found = true;
		}

	}
	if (!found)
	{
		cout << "NOT FOUND" << endl;
	}
}

// Function: Tomato
// Purpose: To assign a FRESH or ROTTEN tag to a movie based on rating.
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: ROTTEN and FRESH
// Function Called: none
// Error Messages: none
string Tomato (int score)
{
	if (score <= 59)
	{
		return "ROTTEN";
	}
	else 
		return "FRESH";
}

// Function: SaveFile
// Purpose: To save any changes to the file 
// Input: none
// Output: none
// In Param: score
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void SaveFile( Movie* movie[], int count)
{
	ofstream outfile;
	outfile.open("tomatoes.txt");
	
	if(outfile.is_open())
	{
		for (int i = 0; i < count; i++)
		{
			outfile << movie[i]->nameOfMovie <<'|' << movie[i]->scoreOfMovie << endl; 
		}
		outfile.close();
		cout << "SAVED TO FILE." << endl;
	}
}

// Function: DeletePtr
// Purpose: To free space allocated by the pointer array after the program ends.
// Input: none
// Output: none
// In Param: moviePtr, count
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void DeletePtr(Movie* moviePtr[], int count)
{
	for(int i = 0; i < count; i++)
	{
		delete moviePtr[i];
		moviePtr[i] = 0;
	}
	
}

// Function: PrintLine
// Purpose: To format the output
// Input: none
// Output: none
// In Param: size, ch
// Out Param: none
// Return: none
// Function Called: none
// Error Messages: none
void PrintLine (int size, char ch)
{
	cout << setw(size) << setfill(ch) << ""
         << setfill(' ') << endl;
}
Topic archived. No new replies allowed.