This is my first program attempt in C++. I'm having some logical issues in a program I wanted to made to test my knowledge on C++ so far after reading up through chapter 3 of "Thinking in C++" - by Bruce Eckel.
It's suppose to be a word processor - I broke up different tasks into functions so that I could have the menu continue to display menu options after each function and only quit the program when I press c.
However, the program's menu function is acting odd - repeating twice some times before it performs the wanted function and when I try to select a new document for the second time, after I already have created a new document and saved it, it just exits.
Well without running it, the first thing that jumps out at me is your main function. You are checking menu() returns before you even show the menu.
Should be:
1 2 3 4
menu(); // run menu
if(menu() == 1)
newFile();
// rest of if statements
Also might want to consider making it so the choice is put in a variable and use that to check against rather then the functions return value directly.
1 2 3 4 5
int choice = menu();
// then do something like
if(choice == 1)
newFile();
// etc
@BHXSpector how could you miss that each time an if statement is evaluated it calls menu() again? ;)
@OP you need to call menu() ONCE at the start of the program and store its return value in a variable, then sue that variable in the if statements. Otherwise each if statement calls the menu() again.