ptr=”Hello”
for(i=0;i<strlen(ptr);i++)
{
printf(“default address:%p and it is pointing at %d whose address is : %p and value at this address is %c “,&ptr,i,ptr,*ptr);
ptr++
}
when executing the above loop printf command only prints “Hel” instead of “Hello”.
why is the string length decreasing with progressing of the loop?
hi,
Because You are increasing both i and ptr.. analyze their values in the loop… you will get your answer.
thnx