int main()
{
char arr[] = “geeksforgeeks”;
char *ptr = arr;
while(*ptr != ‘\0’)
++*ptr++;
printf("%s %s", arr, ptr);
getchar();
return 0;
}
output:
hffltgpshfflt
i am not able to understand the output
int main()
{
char arr[] = “geeksforgeeks”;
char *ptr = arr;
while(*ptr != ‘\0’)
++*ptr++;
printf("%s %s", arr, ptr);
getchar();
return 0;
}
output:
hffltgpshfflt
i am not able to understand the output
The ascii value of each charcter of the string is getting incremented by 1.
Initially ptr pointer holds the base address… (or it points to the first character)
++*ptr++;
This line means that increase the ascii value of the current character(where ptr points) by one…and then make the ptr pointer point to the next character.
So by this was final output comes as
hffltgpshfflt
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.