declare variables inside switch

when declare varibles or objects inside a switch statement, brackets are needed.

example

switch(a) { case 1: { char* filename="data.txt"; break; } case 2: {...} default:break; }

otherwise you'll get "crosses initialization fault..."

你可能感兴趣的:(initialization,variables)