Code:
case 's':
ofstream save_file ("mudsave.txt");
save_file<<"Test Test Test";
save_file.close();
ifstream load_file ("mudsave.txt");
cout<<load_file;
cin.get();
break;
This is just a small part of my code where I am, of course, trying to read and write a file. These are the errors I get when I try to compile it:
Code:
/home/account/cpp/mud.cpp: In function `int main(int, char**)':
/home/account/cpp/mud.cpp:218: error: jump to case label
/home/account/cpp/mud.cpp:212: error: crosses initialization of `
std::ifstream load_file'
/home/account/cpp/mud.cpp:209: error: crosses initialization of `
std::ofstream save_file'
/home/account/cpp/mud.cpp:221: error: jump to case label
/home/account/cpp/mud.cpp:212: error: crosses initialization of `
std::ifstream load_file'
/home/account/cpp/mud.cpp:209: error: crosses initialization of `
std::ofstream save_file'
/home/account/cpp/mud.cpp:250: error: jump to case label
/home/account/cpp/mud.cpp:212: error: crosses initialization of `
std::ifstream load_file'
/home/account/cpp/mud.cpp:209: error: crosses initialization of `
std::ofstream save_file'
/home/account/cpp/mud.cpp:255: error: jump to case label
/home/account/cpp/mud.cpp:212: error: crosses initialization of `
std::ifstream load_file'
/home/account/cpp/mud.cpp:209: error: crosses initialization of `
std::ofstream save_file'
/home/account/cpp/mud.cpp:218: warning: destructor needed for `std::ifstream
load_file'
/home/account/cpp/mud.cpp:218: warning: where case label appears here
/home/account/cpp/mud.cpp:218: warning: (enclose actions of previous case
statements requiring destructors in their own scope.)
/home/account/cpp/mud.cpp:221: warning: destructor needed for `std::ifstream
load_file'
/home/account/cpp/mud.cpp:221: warning: where case label appears here
/home/account/cpp/mud.cpp:250: warning: destructor needed for `std::ifstream
load_file'
/home/account/cpp/mud.cpp:250: warning: where case label appears here
/home/account/cpp/mud.cpp:255: warning: destructor needed for `std::ifstream
load_file'
/home/account/cpp/mud.cpp:255: warning: where case label appears here