0
我得到了這段代碼..現在挑戰性的部分是我的教授要求我製作一個程序,要求用戶輸入大寫字母。在C ..中將大寫字母轉換爲小寫字母(具有挑戰性)
問題是,她希望程序自動將每個輸入的字母大寫,即使用戶的鍵盤不處於大寫鎖定模式..所以我不知道什麼是我的程序錯誤...任何人?幫幫我??我真的需要它..感謝..
#include<stdio.h>
#include<ctype.h>
#include<string.h>
typedef char String[100];
main()
{
char Resp;
int l, x = 0, asc = 13;
String s, word1;
clrscr();
do {
printf("\n1st uppercased word: ");
do {
s[0] = getch();
word1[x++] = s[0];
strupr(s);
strcat(s, "\0");
puts(s);
} while (s[0] != (char) asc);
strcat(word1, "\0");
printf("\n\n1st word in lowercase: ");
for (l = 0; l < strlen(word1); l++)
putchar(tolower(word1[l]));
printf("\nDo you want to continue?[Y/N]: ");
Resp = getche();
} while (toupper(Resp) == 'Y');
getch();
return 0;
}
你應該告訴你的教授他的意思是什麼,因爲說這樣的話毫無意義。再加上你的代碼真的很難讀取它的縮進。 – 2010-07-28 01:22:49
@thyrgle:對我有意義---檢查我的答案。 – Jacob 2010-07-28 01:24:35
@Jacob:哦......好的......不過,我解釋過,你需要製作一個程序,將所有內容都轉換爲大寫。現在我想讓你確保所有這些與用戶按下大寫鎖定功能無關。 – 2010-07-28 01:28:00