将大写字母转换成小写字母

xiaoxiao2021-02-28  92

/*将字符串中的大写字母转化成小写字母*/ #include <stdio.h> #include <string.h> void trans (char *str) { char *p = str; while (*p) { if (*p > 'A' && *p < 'Z') { *p +=( 'a' - 'A'); //转换p = p - A + a } p++; } puts (str); } int main() { printf ("Function : Transform 'A' to 'a'.\n"); char str[100]; fgets (str, sizeof(str)/sizeof(char), stdin); trans (str); return 0; }
转载请注明原文地址: https://www.6miu.com/read-71928.html

最新回复(0)