str here refers to a character array of size 50*sizeof(char) . But sizeof(str) prints the sizeof variable of the str variable, not sizeof what it refers to. str here is just a pointer variable, and the pointer variable is an unsigned integer whose size is 8 .
Also, you cannot determine the sizeof link (in this case, the size of the character array). This is because the compiler does not know what the pointer points to.
Change Getting the sizeof of what the pointer points to does not make much sense in C / C ++. Suppose the pointer points to a primitive type (e.g. int , long ), then you can directly do sizeof(int) . And if the pointer points to an array, as in this case, you can directly execute arraySize * sizeof(dataTypeOfArray) . arraySize always known, since C / C ++ does not allow you to define arrays of unknown size, and dataTypeOfArray is known anyway.
Arjun source share