gpt4 book ai didi

c - C 中的上层函数

转载 作者:太空宇宙 更新时间:2023-11-04 03:48:28 24 4
gpt4 key购买 nike

#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;
}

这个程序编译得很好,但是当我运行它时,它没有输出任何东西。我在这里错过了什么?

最佳答案

你没有打印任何东西!

打印toupper()的返回值。

        printf("%c",toupper(*s));

关于c - C 中的上层函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22598292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com