1
#include <stdio.h>
#include <ctype.h>

char* strcaps(char* s)
{
        while (*s != '\0')
        {
                toupper(*s);
                s++;
        }
        return s;
}

.

int main()
{
        char makeCap[100];
        printf("Type what you want to capitalize: ");
        fgets(makeCap, 100, stdin);
        strcaps(makeCap);
        return 0;
}

このプログラムは問題なくコンパイルされますが、実行すると何も出力されません。ここで何が欠けていますか?

4

3 に答える 3

1

あなたは何も印刷していません!

の戻り値を出力しtoupper()ます。

        printf("%c",toupper(*s));
于 2014-03-23T23:03:03.030 に答える
0

何も印刷しないので、もちろん何も出力されません。

于 2014-03-23T23:02:46.103 に答える
0
char* strcaps(char* s){
    char *p;
    for (p=s; *p; ++p)
        *p = toupper(*p);//maybe you want to change the original
    return s;//your cord : return address point to '\0'
}
...
//main
printf("%s", strcaps(makeCap));
于 2014-03-23T23:06:20.663 に答える