Originally Posted by
DiscoStu9
just curious, why did you chose to use the switch statements? why not a set of 4 instructions since we know that going in...with i<4
The switch statement would be 4 instructions. Eg: guessing that line 3 is the dimensions and that line 4 is the palette size (I'm probably wrong), you could do something like:
Code:
struct pgm_info thisimage = malloc(sizeof(struct pgm_info));
[...all that other stuff...]
case (2): sscanf(buffer,"%d %d",thisimage.width, thisimage.height);
break;
case (3): sscanf(buffer,"%d",thisimage.palette);
You could just use a sequence of if(i==2) statements to accomplish the same thing.