4 ms·
C does not have implicit casts
by downvotetruth 4y ago
C does not have implicit casts
- chlorion 4y agoC most certainly does have implicit casts, and they are everywhere. Simple example: // malloc returns *void, but C casts it to *char char *p = malloc(10); There are tons of implicit casts when working with integers of different sizes, another example: // subtraction of ints of different signedness // C casts signed int 10 to an unsigned int assert(2U - 10 == 4294967288); Arrays decay into pointers which is another implicit cast, I don't think an example is needed though. Anyways these are just a few common examples, there are tons more and many of them are pretty subtle and error prone. https://en.cppreference.com/w/c/language/conversion https://en.cppreference.com/w/c/language/conversion
- deleted 4y ago[deleted]