while(*p!='\0'){ p++; len++; } for(i = 0;i<len/2;i++){ char temp = *(s+i); *(s+i) = *(s+len-1-i); *(s+len-1-i) = temp; }