Finding the length of a Character Array in C

not_l33t picture not_l33t · Nov 15, 2010 · Viewed 293.4k times · Source

What is a way in C that someone could find the length of a character array?

I will happily accept pseudo-code, but am not averse to someone writing it out if they'd like to :)

Answer

Daniel A. White picture Daniel A. White · Nov 15, 2010

Provided the char array is null terminated,

char chararray[10] = { 0 };
size_t len = strlen(chararray);