0
#include<stdio.h>

int main()
{
    char arr[] = "hello";
    printf("str = %s, %ld %ld\n",arr, sizeof(arr), sizeof(*arr) );

    return 0;
}

The above program returns: str = hello, 6 1

whereas,

#include<stdio.h>

int main()
{
    char *arr = "hello";
    printf("str = %s, %ld %ld\n",arr, sizeof(arr), sizeof(*arr) );

    return 0;
}

this program returns str = hello, 8 1

Why the returns of sizeof(arr) is different in these two cases?

0 Answers0