Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //郭翔宇
- //英文字母小寫轉大寫
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- system("color f0");
- char input[51] = {};
- char output[51] = {};
- printf("請輸入英文字母:");
- scanf("%50s", &input);
- printf("input = %s\n", input);
- int i = 0;
- for (i = 0; input[i] != '\0'; i++)
- {
- if (input[i] >= 'a' && input[i] <= 'z')
- {
- output[i] = input[i] - ('a' - 'A');
- }
- else
- {
- output[i] = input[i];
- }
- }
- printf("output = %s\n", output);
- printf("\n");
- system("pause");
- return 0;
- }
- /*
- 【程式執行結果】
- 請輸入英文字母:abcd efgh
- nput = abcd
- utput = ABCD
- 請按任意鍵繼續 . . .
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement