EmbLogic's Blog

e-14

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?

One Response to e-14

  1. manoj says:

    hi,

    Because You are increasing both i and ptr.. analyze their values in the loop… you will get your answer.

    thnx

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>