|
-
August 7th, 2007, 03:51 AM
#7
Re: help w/ my prog : i just cant get the hang of these pointers :(
Code:
#include <iostream>
#include <string>
using namespace std;
struct movies{
string title;
int year;
} movie[max];
void listmovies(int& max){
int i=0;
while (i<max){
cout<<movie[i]->title<<" ("<<movie[i]->year<<")\n";
i++;
}
}
void entermovies(){
movie = new (nothrow) int[count];
for (int i=0;movie[i]==0;i++){
cout << "Error: memory could not be allocated";
system("pause");
}
// movies * pmovie;
// pmovie = &p[m];
cout<<"Enter the name of a movie: ";
cin>>movie[count]->title;
cout<<"Enter that movie's year: ";
cin>>movie[count]->year;
cout<<"\n\n You have entered: \n"<< movie[count]->title<<" ("<<movie[count]->year<<")\n\n";
count++;
cout<<"Would you like to enter another movie (m) or view the list (l) or exit (e)? \n";
int input;
cin>>input;
switch (input){
case 'm':
entermovies();
case 'l':
listmovies();
case 'e':
return 0;
}
}
int main(){
string * p;
int max = 0, count = 0;
movies * movie[m];
system("TITLE Movie Database");
// system("CLS"); clears the screen
cout<<"Movie Database \n\n";
entermovies();
system("pause");
return 0;
}
in facing the errors mentioned above, i just need to get the program running , then i can handle the bugs (atleast i think)
Last edited by elninio; August 7th, 2007 at 04:10 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|