Consider this part of your code:
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
|
void titleopen ()
{
char title [20];
ifsream titlebox ("titlebox.txt");
getline (cin,title);
titlebox.close;
cout >> title >> "Is announcing:" >> endl;
return (0);
}
void messageopen()
{
char message [300];
ifstream messagebox ("messagebox.txt");
getline (cin,message);
messagebox.close;
cout << message << endl;
return (0);
}
| |
1. In both functions you are trying to close the files after reading from them. To close a file, you call the close() function, for example:
filename.close();
You forgot to put the () after close in both places. close is a function call, it needs ().
2. Your both functions are of type void. They don't return anything. But still you have included return(0) at the end of both functions. Remove return(0) from both.
Taking another part of your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
int main()
char yesno;
{
title ();
message ();
cout << "press Y to exit" << endl;
cin >> yesno;
if (yesno == y)
{
cout << "good bye" << endl;
break;
}
else
{
cout << "You did not press Y" << endl;
}
return (0);
}
| |
1. I can't see the { after your main()
2. if (yesno == y) tries to compare the contents of the char variable yesno with y. y should be a char constant. Then you should put it as 'y'
3. break is used to exit a loop. I can't see a loop in your code. break is meaningless here. You need to remove it.
Check these and then reply if it compiles and works as expected. And finally a general note: style is essential to make your code readable. Please use indentation.