#include <stdio.h>
#include <string.h>
int string_length(char s[]) {
int i = 0;
while(s[i]!='\0')
i++;
return i;
}
void string_reverse(char st[]) {
int i,j,len;
char ch;
j = len = string_length(st) - 1;
i = 0;
while(i < j) {
ch = st[j];
st[j] = st[i];
st[i] = ch;
i++;
j--;
}
}
int main (void) {
char line[] = Taj Mahal is one of the seven wonders of the world;
char reverse[100]=,temp[50];
int i,j,n;
n = string_length(line);
for(i = 0; i < n; i++) {
for(j = 0; i < n && line[i]!=' '; ++i,++j) {
temp[j] = line[i];
}
temp[j] = '\0';
string_reverse(temp);
strcat(reverse, temp);
strcat(reverse, );
}
printf(Original - %s\n, line);
printf(Reversed - %s\n,reverse);
return 0;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。