"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:42***************@news.individual.net...
"lasek" <cl**************@acrm.it> wrote:
char acName[]="Claudio";
unsigned int uiLen;
uiLen=strlen(acName);
printf("Length of acName variable %u",uiLen);
printf("acName[iLen]: [%c]",acName[iLen]);
i should see something like [o].
Why i see only [] ?.
Because arrays in C are zero-based. This should be the second thing your
C text book teaches you about arrays, just after the difference between
arrays and pointers.
Richard
IOW, you are pointing past your string to the terminating null character.
Null characters don't often have a display representation. The last
character 'o' is at acName[uiLen - 1]
Also, you should take care in some of the terminology.
The length of acName variable is really sizeof(acName). This is the number
of bytes (chars) of storage used. To be pedantic, if your char type is not
byte-sized, you could use (sizeof(acName) / sizeof(acName[0])) to get the
number of elements available in the array.
The length of the string CONTAINEDIN the variable is strlen(acName)
a string only goes up to the first null character, so it can be smaller than
the array.
Rufus