Another really common one is that casting from void * to any other type doesn't require a cast in C, but it does in C++:
#include <stdlib.h>
int main()
{
int *foo = malloc(sizeof(int));
return 0;
}
That works in C, but not in C++.
There's actually another subtle different in there that main() means "unspecified arguments" in C, and "no arguments" in C++. ("No arguments" in C would be main(void).) However, it's no longer commonly used that way in C, but casts from void * to other types is very common in C.
There's actually another subtle different in there that main() means "unspecified arguments" in C, and "no arguments" in C++. ("No arguments" in C would be main(void).) However, it's no longer commonly used that way in C, but casts from void * to other types is very common in C.