#include <stdio.h>
int main(void) {
char strp[] = "hello";
char strq[] = " world";
strcat(strp,strq);
puts(strp); //hello world
printf("%d",sizeof(strp)-1);//this gives 5(length of 'hello' -1 for '\0')
printf("%d",strlen(strp));//gives correct answer(11)
return 0;
}
Why does sizeof give wrong answer but strlen give right answer in this case?