3 ms·
It seems that everyone's forgetting the whole genius thing about C-strings, which is that you can iterate through them without advance knowledge of their length
by derefr 13y ago
It seems that everyone's forgetting the whole genius thing about C-strings, which is that you can iterate through them without advance knowledge of their length:
char c;
while(c = *(str++))
...
This is, after all, the loop strlen() itself performs.
- vidarh 13y agoWhich is great if you're guaranteed to advance one character per loop iteration. Which may or may not hold.
- goldenkey 13y agoTrue, this is even better in terms of complexity. I'd be curious to know if constantly changing the pointer causes certain cpus to execute this slower than doing a DWORD PTR [EAX + EDX] where EDX is the counter and EAX is the start of the str.