First, to answer the question about how to get back to the menu, add this code to your main. I've put *** at the start of lines that I've added, so you'll need to remove the ***:int main()
{
int option;
***char doMore = 1;
***while (doMore) {
system("title Shibby Inc. (c) 2004");
cout << "What would you like to do?" << endl;
cout << "1 - Find a File." << endl;
cout << "2 - View the locations of the file specified." << endl;
cout << "3 - Quit.\n_\b";
cin >> option;
switch(option)
{
case 1 : find();
break;
case 2 : view();
break;
case 3 : cout << "\n\n(C) Shibby Inc. 2004 - Thank you :)" << endl;
system("pause");
***doMore = 0;
return 0;
break;
default : cout << "Please only make one of the choices given." << endl;
system("pause");
}
***} // end of while loop
return 0;
}
The above changes add a while loop that loops until option three is selected.
while (doMore) {
is the same as:
while (doMore != 0) {
Looking thru your code, I noted:
system("title Shibby Inc. (c) 2004");
The system command sends the string as a command to run on the Windows system. So this is trying to run a command named 'title'. I'm guessing that what you really want here is to echo the output.
One more thing:
void find()
{
char strng[25];
cout .....
cin >> strng;
cin will allow the user to input more than 25 characters. If they do, the extra characters will be stored as if the array were big enough to hold them. This could cause problems in the program because you'll be overwriting memory on the stack (an advanced topic).
I don't know the proper C++ way to prevent this. I use a C input function to handle this (it'll work in C++).
char strng[25];
fgets(strng, 25, stdin);
if (strng[ strlen(strng)-1 ] == '\n') {
strng[ strlen(strng)-1 ] = '\0';
}
This will input until 24 characters are read (leaving 1 char for null) or until a newline is read. Because of the 'stdin', it is reading from standard in (normally the keyboard). fgets also leaves the newline on, so the if checks for and removes the newline if it is there.
Be sure to come back and let us know if our suggestions helped!