Possible Duplicate:
How to find the sizeof(a pointer pointing to an array)
sample code written in c
#include<stdio.h>
int main()
{
char a[]="Visual C++";
char b[] = "Visual\C++";
printf("%d, %d\n", sizeof(a), sizeof(b));
printf("%d, %d", sizeof(*a), sizeof(*b));
return 0;
}
OUTPUT
11,10
1,1
1.) Why sizeof(a) shows 11, although, it has only 10 characters.
2.) Why sizeof(a) and sizeof(b) showing different output, although, they have same number of characters.
Because there is a
null(\0) at the end of the string and\Cis interpreted as a single character.If you want the backslash to show in a C string you must escape it using another backslash.