c - 我如何确定此代码符合哪个 C 标准?

标签 c

在 C 实验室中出现了这个 super 简单的代码:

#include <stdio.h>

int suma (int a, int b)
{
        return a+b;
}

int mult (int a, int b)
{
        return a*b;
}

int main(void)
{
        int a,b;
        printf ("Operando 1: ");
        scanf("%d",&a);
        printf("Operando 2: ");
        scanf("%d",&b);
        printf("%d+%d=%d\n",a,b,suma(a,b));
        printf("%d*%d=%d\n",a,b,mult(a,b));
        return 0; 
}

通过查看代码,我应该确定它符合哪个 C 标准(ANSI、ISO 或事实上的 K&R)。看完thisthis我倾向于说它符合三个标准。那是正确的吗?

最佳答案

这不是 K&R。 K&R 函数声明在括号外定义参数,如下所示:

int mult (a, b)
    int a;
    int b;

void 是在第一个 ANSI 标准中引入的。

对我来说,它似乎同时符合 ANSI C89 和 C99。

关于c - 我如何确定此代码符合哪个 C 标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3752979/

相关文章:

混淆 while 和 for 循环的变量作用域(C 编程)

c - 理解fputc

c - 使用我的字符驱动程序时出现段错误

c++ - 是否有用于从 HTML 页面中提取数据的库?

C fscanf 数据搞砸了

c - Visual Studio 2019 : Cannot change Runtime Library : Error "Element <RuntimeLibrary> has an invalid value of/MDd "

c - 是否可以使用变量声明数组?

c - opengl:如何在调整大小时将对象保留在窗口中

c - 编写一个 C 函数,将数字四舍五入为 2 的下一个幂

c - dcraw的gamma_curve实现的算法叫什么名字?