4 ms·
From slide 12: int my_var = 3; // It's an int! my_var = "abc"; // COMPILER ERROR! You clearly stated that it was an int! "abc" gets interned and has a
by readme 11y ago
From slide 12:
int my_var = 3; // It's an int!
my_var = "abc"; // COMPILER ERROR! You clearly stated that it was an int!
"abc" gets interned and has a memory address. The statement my_var = "abc" tries to assign that address to my_var, but since it's not a pointer to char it gets cast to int instead, possibly truncating the value.
The program still compiles, just printing a warning.