I am a beginner in C programming. I recently tried solving a simple problem to find the short form of a string. I can't understand why we are using *(ptr+i-1) in the program. What if I use only * (ptr+i). Can anyone please tell me how this works?
#include<stdio.h>
#include<string.h>
int main()
{
    char sent[100];
    char *ptr;
    printf("Enter a sentence : ");
    gets(sent);
    char len=strlen(sent);
    printf("%c",*sent);
    ptr=&sent;
    for(int i=1; i<len; i++)
    {
        if(*(ptr+i-1) == ' ')
        {
            printf(" %c",*(ptr+i));
        }
    }
    return 0;
}
 
     
    