(5)实现一个函数,把一个字符串中的字符从小写转为大写。

#include "stdio.h"
#include "conio.h"
#include "stdafx.h"
#include <iostream>
using namespace std;

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);
system("pause");
}

posted @ 2016-02-29 10:27  水木_清风  阅读(1662)  评论(0编辑  收藏  举报