-
files
is there a way to jump to a seperate file with code?
for example
Code:
#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"choose from menu\n";
cout<<"1, search phone book\n";
cout<<"2, edit phone book\n";
cout<<"\n";
cout<<"input : ";
cin>> x;
switch ( x )
{
case 1:
cout<<"goto different file";
cin.get();
break;
case 2:
cout<<"goto different file";
cin.get();
break;
default:
cout<<"incorrect input";
cin.get();
break;
}
}
-
Yes. Just open the file and process it as required - I'd create two functions (one for choice 1 one for choice 2) that process each file as necessary.
Code:
switch ( x )
{
case 1:
SearchPhoneBook();
break;
case 2:
EditPhoneBook();
break;
default:
cout<<"incorrect input";
cin.get();
break;
}
-
Each file stream can be associated with only one file at a time. However, you can have multiple file streams in any given project and you can change files associated with a given stream as long as you close the first file before associating the stream with the second file.