c - 我的 C 程序给出了相同的计算结果

标签 c codeblocks

#include <stdio.h>
main()
{
    int a,b,c;
    printf("write two numbers");
    scanf("%d%d", &a,&b);
    c=a+b;
    printf("the sum of two numbers is%d",&c);
}

这是我使用的代码。 我正在使用代码块进行编译。

最佳答案

使用printf()时,您打印的是位置而不是c变量的值。删除&即可获取c的实际值。

printf("the sum of two numbers is%d",c)

关于c - 我的 C 程序给出了相同的计算结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50716241/

相关文章:

c++ - “输入”未命名类型错误。不知道为什么吗?

c++ - Windows 上的 Armadillo 和 Codeblocks

C++ 函数错误——无法将大括号括起来的初始值设定项列表转换为 char*

C 编程,服务器套接字从客户端调用文件时出现错误

c++ - Code::Blocks - Linux - 打印 "Hello World",即使它不在 "main.cpp"文件中

c++ - 为什么我会收到 "was not declared in this scope"错误?

c - c中字符数组结束后会发生什么?

c - 使用 fscanf 检查是否存在更多行

c - 在 GCC 中以编程方式调用调试器

c++ - cuda在gpu和主机之间统一内存