Consider the following code
#include
void print(char string[]){
printf(\"%s:%d\\n\",string,sizeof(string));
}
int main(){
char string[] =
You asked the systems for the sizeof(the address to the begining of a character array), string is an object, to get information about it's lenght out you have to ask it through the correct OO interface.
In the case of std::string the member function string.length(), will return the number of characters stored by the string object.
It is the size of the char pointer, not the length of the string.
Use strlen from string.h to get the string length.