#include <stdio.h> #include <string.h>

int main() { char str[101]; int len, i;

printf("请输入一个字符串:");
scanf("%s", str); // 输入字符串

len = strlen(str); // 获取字符串长度

printf("颠倒后的字符串为:");
for (i = len - 1; i >= 0; i--)
{
    printf("%c", str[i]); // 逆序输出字符串
}

return 0;

}

C语言字符串反转:颠倒字符串内容

原文地址: https://www.cveoy.top/t/topic/oONZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录