C - We Should Never Use Function Sizeof to Calculate Size of a Pointer Which Points to String
Code: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; char *str = "1234567890"; printf("Size of arr is %d\n", sizeof(arr)); printf("Size of *arr is %d\n", sizeof(*arr)); printf("String length of arr is %d\n", strlen(arr)); printf("Size of str is %d\n", sizeof(str)); printf("Size of *str is %d\n", sizeof(*str)); printf("String length of str is %d\n", strlen(str)); return 0; } Output: Size of arr is 10 Size of *arr is 1 String length of arr is 9 Size of str is 8 Size of *str is 1 String length of str is 10