Sunday, 15 September 2013

Odd result of compiling a C code

Odd result of compiling a C code

I just compiled this source :
#include <stdio.h>
int main()
{
char card_name[0];
puts ("Please enter : ");
scanf("%s", card_name);
int val = 0;
switch(card_name[0]) {
case 'A':
val = 10;
printf("Hello");
break;
case 'B':
val = 20;
break;
default:
val = 0;
}
return 0;
}
I don't know why , But when you enter some words that starts with 'A' you
got this result : The card value is : 11 Why eleven ?

No comments:

Post a Comment