#include<stdio.h>
#include<string.h>
#include<malloc.h>
char *ReverseString(char *s,int length){
int i=0;
int j=length-1;
char tmp;
if(s==NULL||length==0)
return NULL;
while(i<j){
tmp=s[i];
s[i]=s[j];
s[j]=tmp;
++i;
--j;
}
return s;
}
#define NUM 100
void main(){
int i=0;
char *res;
char *source;
int len;
source=(char*)malloc(NUM*sizeof(char));
memset(source,0,NUM*sizeof(char));
//scanf("%s",source);//输入无空格时可用
gets(source);//输入有空格时使用
len=strlen(source);
res=ReverseString(source,len);
i=0;
while(i<len){
printf("%c",source[i]);
++i;
}
getchar();
}
//遇到的问题
//1. 变量定义位置,某些编译器要求变量在函数一开始就进行定义,不允许随用随定义
//2.关于scanf()、gets()等函数使用问题,上一篇中已总结