// Created by lqmios on 15/12/3.
// Copyright © 2015年 ibokan. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char * argv[]) {
char *p,*start,*end,temp,c;
int count = 0;
int i = 0;
p = (char *)malloc(21*sizeof(char));
printf("输入一串字符串:字符控制在20以内:\n");
while ((c = getchar()) !='\n' ) {
*(p + count) = c;
count++;
}
*(p + count) = '\0';
printf("翻转之前: %s\n",p);
//字符翻转
start = p;
end = p + count - 1;
for (i = 0; i<count / 2; i++,start++,end--) {
temp = *start;
*start = *end;
*end = temp;
}
printf("翻转后: %s\n",p);
return 0;
}