你能告诉我为什么我没有从下面的函数中得到任何价值吗?
#include <stdio.h>
#include <stdlib.h>
typedef struct {
unsigned int length ;
char * data ;
} String ;
String reverse(String this){
String that;
that=this;
int i,j;
j=that.length-1;
char myc[that.length+1];
for(i=0; i < that.length; i++, j--) {
myc[i]=that.data[j];
}
myc[i+1]='\0';
that.data= myc ;
return that;
}
int main()
{
String myStr;
String myStrA;
myStr.data= "This one is beautiful";
myStr.length=21;
String myStr2= reverse(myStr);
printf("\n\nmy text before reverse : %s \n", myStr.data);
printf("\n\nmy text after reverse : %s \n", myStr2.data);
return 0;
}
// 反向函数应该返回一个反转的字符串,但它没有