1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <stdio.h> void Reverse(char* ch,int sz) { int i,j=0; char temp[sz]; for (i=sz-1; i>=0; i--) { temp[j] = ch[i]; j++; } for (i=0; i<sz; i++) { ch[i] = temp[i]; } } int main() { char ch[] = "abcdefghijsdfwdfasdfewfdqxsaefw"; int sz = sizeof(ch)/sizeof(ch[0])-1; Reverse(ch,sz); printf("%s",ch); return 0; }
|