I am taking the first char from a string so mystring[0] and using it as an int on a switch case. The switch case has all ascii values starting at 32 (space) up to 255 grouped into a total of 19 switches. My question is basically if this is okay, or should I do this in a different way? See code:
column is a class of vectors of type struct!
some of the case blocks are very big (20 or 30 "case number:" statements. So I am wondering if I couldn't do this more efficiently!Code:inline column* ptr2col(unsignedint intin)// Returns a pointer to a column class { column* ret; // switch (intin) { //c_01 a q case 1: case 65: case 97: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 81: case 113: ret=&c_01; break; //c_02 e w case 2: case 69: case 101: case 200: case 201: case 202: case 203: case 232: case 233: case 234: case 235: case 240: case 87: case 119: ret=&c_02; break; and so on etc. ............................ till //c_19 Rest case 19: default: ret=&c_19; for every char over 255!
Regards,
Rigsby![]()




Reply With Quote