/*字符串中大写字母变成小写,其余字符不变*/

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

char* mystrlwr(char *s)
{
	char *scopy = s;
	while (*s) {
		if (*s >= 'A' && *s <= 'Z') {
			*s = *s + 'a' - 'A';
		}
		s++;
	}
	return scopy;
}

char *mysed_strlwr(char *s)
{
	char *scopy = s;
	while (*s) {
		if (isupper(*s)) {
			*s = tolower(*s);
		}
		s++;
	}
	return scopy;
}

int main(void)
{
	char s[] = "HeLLowoRLD";
        printf("%s\n", mystrlwr(s)); 
	printf("%s\n", mysed_strlwr(s));
	return 0;
}

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-10-11
  • 2022-12-23
  • 2021-10-04
  • 2021-12-17
猜你喜欢
  • 2021-04-08
  • 2021-10-26
  • 2022-12-23
  • 2021-10-07
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案