4 ms·
That's not really "little known". Almost every single piece of code that does string manipulation in C uses that fact: const char* s = ...; while (*s++) {
by delroth 11y ago
That's not really "little known". Almost every single piece of code that does string manipulation in C uses that fact:
const char* s = ...;
while (*s++) { ... }
- aidenn0 11y agoconstant pointers are arguably little-known, though pointers to constants are well known.
- lmb 11y agoI think you have proven my point. I'm talking about this: void something(const char* const s); Maybe I'm extrapolating here, but it surprised me.
- dcohenp 11y agoThat is indeed what the post you're replying to meant. Note that the pointed-to value is a constant string, yet the pointer itself is being modified. That's a fairly common idiom in C string-handling code, only possible because it's a const char , not a const char const.