Hey, I've been trying to make C++ read a text file where I save some information, and wanted to make it so that the option that would use the save.txt file (case 2) had a check function that checked that it actually was a text file with that name. But I don't know what is wrong here I get the errors:
error C2360: initialization of 'CheckSave' is skipped by 'case' label
error C2360: initialization of 'CheckSave' is skipped by 'case' label
error C2360: initialization of 'CheckSave' is skipped by 'default' label
what can I do?
CODE
bool CheckSaved()
{
ofstream Save;
Save.open ("Save.txt");
if (Save.is_open())
{
return true;
}
else
{
return false;
}
}
int IntroOptions()
{
int IntroNum;
cin >> IntroNum;
switch (IntroNum)
{
case 1:
SaveCreation();
break;
case 2:
bool CheckSave = CheckSaved();
if(CheckSave == true){
something();
}
else{
somethingelse();
}
break;
case 3:
Credits();
IntroOptions();
break;
case 4:
exit(1);
break;
default:
cout << "Please press 1,2,3 or 4!\n";
IntroOptions();
break;
}
return 0;
}