Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Conflating pointers with arrays.

AND Strings.

FTFY.



C doesn't have strings. ;-)


More precisely, it doesn't have a string type.


It certainly has string literals, which are a kind of type.


That's the thing, they're not a type - they're just an array of char with an unspecified length, indistinguishable from any other array of char or pointer to char. Only the convention of ending them with a null character makes them usable at all.


printf("%lu\n", sizeof("Well, actshully")); -> 16


One could say that C has a different type for each string size plus the joker pointer to char.


That's because they were conflated with both arrays and pointers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: