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?
31
Upvotes
View all comments
Show parent comment
1
u/Lopsided-Cost-426 May 08 '26
The C standard mandates sizeof(char) be equal to 1 so a char will always be 1 byte long. That being said there are some extremely old systems that have bytes not equal to 8 bits so while a char is always 1 byte long, it isnt necessarily 8 bits long.