r/cprogramming • u/die-Banane • May 05 '26
How to do strings properly?
I just started learning C and I often read on the internet that it is bad practice to use null terminated strings, so my question is what should I do instead?
30
Upvotes
View all comments
Show parent comment
1
u/imaami May 06 '26
size_t, notint. The latter is likely to be narrower than a pointer, which means if you wrap both in a struct, the struct will have implicit padding. Also,intcan only typically represent values less than 2³¹.