View Single Post
Go4Expert Member
6Mar2012,12:04  
Chong's Avatar
Hi won

Suppose that the input is "happy". Then p[] = word[]="happy" and consonant is 'h' . strcpy(p,p+1) makes p[]="appy" and we let p[4]=p[strlen(word)-1]=consonant. Then we have p[]="appyh". Note that p[i]=*(p+i).

Note that the value of p in the function changes from time to time. We need to know the value of p when the function is called so tmp points to the value of p intially. For example.
char p[]="happy";
char *tmp=p;
printf("%s\n",p);//This prints "happy"
p=p+1;
printf("%s\n",p);//This prints "appy"
p=tmp;
printf("%s\n",p);//This prints "happy"

Best regards
Chong