11 ms·
For this example: char str[256]; str = "asdf" both str and "asdf" are not pointer-type expressions; they're both arrays (which is exposed by sizeof). The r
by int_19h 4y ago
For this example:
char str[256]; str = "asdf"
both str and "asdf" are not pointer-type expressions; they're both arrays (which is exposed by sizeof). The reason why this doesn't work is because C refuses to treat arrays as first-class value types - which is not an obvious thing to do regardless of how well you understand pointers or not. Other languages with arrays and pointers generally haven't made this mistake.