Hi I'm new to C and was wondering whether there is a better way to solve my problem than a switch( ) case statment.
I'm trying to decode a byte of data from an ICMP packet, because it's a byte, it can have 256 different values, with most of the values relating to a different piece of content. Currently i am using this method:
As you can imagine this method is quite time consuming, is there a better/more efficient way to do this?Code:switch (value) { case 0: printf("0 echo reply"); break; case 1: printf("1 unassigned"); break; case 2: printf("2 unassigned"); break; case 3: printf("3 destination unreachable") break; case 4; printf("4 source quench") break; ..... and so on and so on......... until 255
Any help would be greatly appreciated
Thanks