C has automatic casting between
any
2 number data types
- In C, the
C compiler will
always allow
automatic casting -
even when it is
unsafe:
#include <stdio.h>
int main(int argc, char *argv[])
{
int x = 5;
short y;
y = x; // C allows it !!
printf("%d\n", y);
}
|
|
Try other data types, like
casting from
double to
a short !
We say that:
"C is a
weakly typed
programming language" for the
lack of
type checking