c-从小写到大写,将一行的单词打印在另一行的下面



我必须制作一个将小写字母转换为大写字母的小c程序。我已经设法做到了,但是,它的输出还没有完成。以下是我到目前为止所做的:

#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void){
char s[100];
int i;
gets(s);
for(i = 0; i < strlen(s); ++i)
{
    s[i] = toupper(s[i]);
}
printf (s);
}

如果你插入"this is a_test",它的输出将是"this a_test"。然而,它应该是以下内容:

这个

我该怎么做?提前谢谢。

for(i = 0; i < strlen(s); ++i) {
    if(s[i] = ' ')
        s[i] = 'n');
    else
        s[i] = toupper(s[i]);
}

最新更新