#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void upper(char* s, char* us)
{
while(*s != '\0')
{
if(*s >= 'a' && *s <= 'z')
{
*us = *s - 32;
}
else
{
*us = *s;
}
s++;
us++;
}
*us = '\0';//注意不要漏了这一句
}
int main()
{
char A[20],B[20];
printf("Please input a string:\n");
scanf_s("%s", A, 20);
upper(A,B);
printf("%s", B);
printf("%c", A[19]);//A[19]存的是'\0'
}
实现一个函数,把一个字符串中的字符从小写转为大写。
最新推荐文章于 2023-02-16 09:38:18 发布