S
sarathy
Consider the code below.
char a[]="Hello";
char b[5]="Hello";
printf ("%d\n",sizeof(a));
printf ("%d\n",sizeof(b));
Output :
------------
6
5
According to the first initialization ,"Hello" is abbreviated as H e l
l o \0. Hence size is 6
But in the second expression i am able to manage the string hello in 5
bytes.
Does'nt the first case sound ineffecient when compared to the second
one.
Either the compiler must manage the \0 internally in both cases and
print 5.
Else allow the user to specify a size 1 greater than the actual
initializer length in the second case.
Why is this incompatibility???
Sarathy
:wq
char a[]="Hello";
char b[5]="Hello";
printf ("%d\n",sizeof(a));
printf ("%d\n",sizeof(b));
Output :
------------
6
5
According to the first initialization ,"Hello" is abbreviated as H e l
l o \0. Hence size is 6
But in the second expression i am able to manage the string hello in 5
bytes.
Does'nt the first case sound ineffecient when compared to the second
one.
Either the compiler must manage the \0 internally in both cases and
print 5.
Else allow the user to specify a size 1 greater than the actual
initializer length in the second case.
Why is this incompatibility???
Sarathy
:wq