在C中将大写转换为小写..(具有挑战性)

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;
}
Run Code Online (Sandbox Code Playgroud)

Jac*_*cob 11

  1. 获取用户的来信 getch()
  2. 用它将它转换为大写 toupper()
  3. 显示它 putch()
  4. 转到1

您可以添加断点---检查该字符是否为返回键并退出.