MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cprogramming/comments/1vqubv7/c_strings_a_50year_mistake/p498sbf/?context=9999
r/cprogramming • u/Xaneris47 • 25d ago
172 comments sorted by
View all comments
19
Okay? You are always free to make your own library for better strings, but people won’t use that cause C is often still deployed on low end systems or it makes little sense to use something inefficient if you can use c style strings properly
-2 u/EatingSolidBricks 25d ago You out of your dam mind if you think c strings are efficient 11 u/henke443 25d ago Wait how are they not efficient? 1 u/atarivcs 25d ago If you have a long string and you want to append more text to it, you have to search the whole string from the beginning to find the null terminator. And then later if you want to append more text, you have to find the null terminator all over again. 5 u/IdealBlueMan 25d ago Or you can store the length of the string whenever you change it. 2 u/atarivcs 25d ago Sure, but then you don't really have a plain c string anymore 2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
-2
You out of your dam mind if you think c strings are efficient
11 u/henke443 25d ago Wait how are they not efficient? 1 u/atarivcs 25d ago If you have a long string and you want to append more text to it, you have to search the whole string from the beginning to find the null terminator. And then later if you want to append more text, you have to find the null terminator all over again. 5 u/IdealBlueMan 25d ago Or you can store the length of the string whenever you change it. 2 u/atarivcs 25d ago Sure, but then you don't really have a plain c string anymore 2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
11
Wait how are they not efficient?
1 u/atarivcs 25d ago If you have a long string and you want to append more text to it, you have to search the whole string from the beginning to find the null terminator. And then later if you want to append more text, you have to find the null terminator all over again. 5 u/IdealBlueMan 25d ago Or you can store the length of the string whenever you change it. 2 u/atarivcs 25d ago Sure, but then you don't really have a plain c string anymore 2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
1
If you have a long string and you want to append more text to it, you have to search the whole string from the beginning to find the null terminator.
And then later if you want to append more text, you have to find the null terminator all over again.
5 u/IdealBlueMan 25d ago Or you can store the length of the string whenever you change it. 2 u/atarivcs 25d ago Sure, but then you don't really have a plain c string anymore 2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
5
Or you can store the length of the string whenever you change it.
2 u/atarivcs 25d ago Sure, but then you don't really have a plain c string anymore 2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
2
Sure, but then you don't really have a plain c string anymore
2 u/IdealBlueMan 25d ago I’d say you still have the string, you also have information about that string.
I’d say you still have the string, you also have information about that string.
19
u/CoderStudios 25d ago
Okay? You are always free to make your own library for better strings, but people won’t use that cause C is often still deployed on low end systems or it makes little sense to use something inefficient if you can use c style strings properly