int main ()
{
char* tab=new char[14] ;
cout << " lenght with sizeof: "<<sizeof(tab)<<endl;
cout << " length with strlen: "<<strlen(tab)<<endl;
system(" pause");
return 0;
}
I got the output:
length with sizeof: 4
length with strlen: 30
I expect the result of sizeof
but not what return strlen
!
For those who will hurry to publish that it's a duplicate question.
I want to say that it's not the opportunity at all. Because I know about compile time and run-time and many other things concerning strlen
and sizeof
however I cannot find explanation to this result.
Thank you for help in advance.