要求使用C语言,将一个字符串逆序,以下是我的代码,一直编译不出结果,哪位大佬帮个忙,谢谢啦
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char * Reverse_Order(const char *str);
int main(int argc,const char* argv[])
{
char *str = "hello";
printf("逆序后为:%s\n", Reverse_Order(str));
free(Reverse_Order(str));
return 0;
}
char * Reverse_Order(const char *str)
{
char *Reverse = NULL;
Reverse = (char *)malloc(10);
int num = 0;
while(*str != '\0')
{
str += 1;
num++;
}
while(*str != '\0')
{
int i=0;
Reverse[i++] = str[num--];
}
return Reverse;
}