Transfer of control bypasses initialization
Hi all,
i have a switch command. and in case the user enters the command 's' (save), i create an output file, and save the data..
but then a compile error was given as "transfer of control bypasses initialization of:"
Code:
case 's':
ofstream output_file;
output_file.open(filename);
.... some code....
output_file.close();
break;
case 'x':
break;
}
what is the problem here, i need the output file only in this case, why is the compiler complaining and what is the solution ?
thanks