以下,我的代码可用
int size(char *);
void reverse(int, int, char*);
int main()
{
char *str="Hello World";//This sentence reverses using function reverse
int len = size(str);
reverse(0,len,str);
cout<<str;
return 0;
}
int size(char *arr){
int rslt=0;
while(arr[rslt]!='\0'){
rslt++;
}
return rslt;
}
void reverse(int strt, int end, char *arr){
char tmp = 0;
for(;strt<end; strt++){
tmp = arr[strt];
arr[strt] = arr[end-1]; //<------------------Marked
arr[end-1] = tmp;
end--;
}
}
当涉及到标记点时,它停止了程序,感谢您的帮助。