0
Why this statement is legal C statement?? int apple = ‘c’ ;
Why this statement is legal C statement?? int apple = ‘c’ ; Isn't int for numbers??
2 odpowiedzi
+ 1
its legal because C reads every character as an integer.
for instance, test this:
int apple = 'a';
printf("int: %d\nchar: %d",apple,apple);
// will print
97
a
because to C, the character 'a' and the number 97 are the same thing.
+ 1
Integer for any known character is its ASCII value in most programming language.
Refer this: http://www.asciitable.com/