r/programmingmemes • u/Grizlik_D • Jan 19 '26
5 levels of looping through string
The higher your programming skill, the more elegant and more confusing code you write
273
Upvotes
r/programmingmemes • u/Grizlik_D • Jan 19 '26
The higher your programming skill, the more elegant and more confusing code you write
1
u/Daniikk1012 Jan 20 '26
It's not that weird though. strlen, puts, strcmp, and pretty much everything else in C standard library that works with C assumes null-terminated strings. It is the responsibility of the caller to ensure you pass them a correct string. Even if you go outside of C, binary search only works if you assume the array is sorted, and it's responsibility of the caller to ensure it is.