Alex Rivera | Logout

C++11 char16_t strlen-equivalent function

Asked 2011-04-28T12:22:05.260
12

I have a simple question: Is there a way to do a strlen()-like count of characters in zero-terminated char16_t array?

Edit
Report

1 Answer

2

Use pointers :), create a duplicate pointer to the start, then loop through it while (*endptr++);, then the length is given by endptr - startptr. You can actually template this, however, its possible the the compile won't generate the same intrinsic code it does for strlen(for different sizes ofc).

answered 2011-04-28T13:01:22.487

Your Answer