c - C 中的上层函数

标签 c function toupper

#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/

相关文章:

c++ - 将指针传递给 C++ 中的方法导致奇怪的输出

计算文本文件中的字符使用情况? C

c++ - 将 cstring 转换为驼峰式

c - 在 OCaml 库中只运行一次代码

c - 使用 mingw32 在 Windows 上构建 glew 时 `DllMainCRTStartup@12' 的多个定义

c++ - 具有显式类型名称的函数模板

javascript - 我应该在函数内部还是外部声明一个变量?

javascript - 如何使用 for 循环向 JS 变量添加值?

python - Python 的 C 和 C++ 库如何跨平台?

c - 如何获取指向文件地址的 const int