In order to use the ifstream fin variable that you declare inside the switch statement, you need to declare it outside the switch statement. For example:
ifstream fin;
switch(choose) {
case 1:
fin.open("whatever.txt");
// ...
}
while(fin >> whatever) // ...
[edit] Wow, I was beaten by over half an hour. Sorry.
Just one other thing to add: why not let the user enter the name of the file themselves? That way you don't have to worry about the switch statement or anything . . . . [/edit]
Last edited by dwks; Jul 2nd, 2008 at 5:20 pm.
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell