C -> sizeof string is always 8

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).


It is treating it as a pointer, the sizeof a pointer is obviously 8bytes = 64 bits on your machine