I guess what you mean was
Code:
while( *(hand + i) != NULL ) // same as hand[i] != NULL
Better way to implement your function would be to add an extra argument telling the number of element to check
Code:
unsigned short int
sum_up_hand(struct card_t *hand, int nbOfCards )
There's also different ways of doing this...
And your function value_of_card seems overly complicated. Also, i don't know if you realized that this loop
Code:
for(i = 0; i < 10; i++)
{
value = ( n == i ) ? i + 1 : 0;
}
was in fact equivalent to this
Code:
value = (n == 9) ? 10 : 0;
i = 10;
As for this
Code:
switch( n ) {
case 10: //jack
value = 10;
break;
case 11: // queen
value = 10;
break;
case 12: //king
value = 10;
break;
}
could be replaced with this
Code:
if (n >= 10)
value = 10;
And by the way, the format specifier for unsigned variable is %u, whatever it's an unsigned char, short or int. But i'm not sure this would have lead to incorrect output, since an unsigned short promoted to an (signed/unsigned) int wouldn't have mess with the sign bit of the int, in the case int is of larger size than short. But i'm not 100% sure.