I could not find your logic correct. But I can say the reason for the exception. In the first for loop you are incrementing i value twice per...
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
Separate names with a comma.