I am confused with this program.
#include <stdio.h>
int main(void)
{
char* ptr="MET ADSD";
*ptr++;
printf("%c\n", ptr);
ptr++;
printf("%c\n", ptr);
}
Here’s the output.
ET ADSD
T ADSD
My question is how does the pointer display the rest of the characters?
You are passing a wrong combination of parameters to
printf: the%cformat specification requires acharparameter, not achar*. So the result is undefined – in your caseprintfseems to print the whole char array, but this is just by pure chance. Use eitheror