c - 如何在 C 中打印

标签 c

我是 C 语言的初学者,事实上这是我的第一个测试程序。

我实际上不知道如何将这个数字打印到终端。

#include <stdio.h>

int addNumbers(int a, int b)
{
    int sum = a + b;
    return sum;
}

int main(void)
{
    int a = 4;
    int b = 7;

    printf(addNumbers(a,b));
    return 0;
}

我敢肯定,在 Java 中,我只需将 printf 替换为 System.out 就可以了。我之前尝试搜索答案,但如果您不知道要搜索什么,就很难找到答案。

最佳答案

试试这个:

printf("%d", addNumber(a,b))

这是 documentation for printf .

关于c - 如何在 C 中打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2162758/

相关文章:

c - 带有结构的 Malloc

C浮点变量不存储小数

C scanf 字符串数组

在树莓派裸机编程中创建 C 库 stub

c - 这是 lapack 问题还是我的代码中的错误?

c - [功能] 之前出现错误 : expected '=' , ',' 、 ';' 、 'asm' 或 '__attribute__'

c - c中的订购号和字符串

c - 在 C 中的 sem_wait 中做一些事情

c - mysql语法中的bit_expr是什么?

c - 未完全填充的数组的大小