Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
yarrel
· 6y ago · 0 comments
C doesn't have strings. ;-)
Comments
[–]
Snarwin
6y ago
More precisely, it doesn't have a string
type
.
[–]
Skunkleton
6y ago
It certainly has string literals, which are a kind of type.
[–]
mark-r
6y ago
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.
[–]
Skunkleton
6y ago
printf("%lu\n", sizeof("Well, actshully")); -> 16
[–]
tus88
6y ago
That's because they were conflated with both arrays and pointers.