There is no string
data type in C. Is this C++? Or is string
a typedef?
Assuming string
is a typedef for char *
, what you probably want is strlen
, not sizeof
. The 8 that you are getting with sizeof
is actually the size of the pointer (to the first character in the string).