小编war*_*una的帖子

scanf需要额外的参数为什么?

我是c ++的新手,我开发用于扫描以获取输入参数.但我给了两个输入参数.但程序允许我输入额外的参数.请解释一下为什么会这样.请在下面找到使用的代码II.

#include <iostream>

int main(int argc, const char * argv[]) {

    int a,b;


    scanf("%i %i ",&a,&b);

    printf("a-> %i",a);
    printf("b-> %i",b);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出(允许40作为额外参数)

20
    30
    40
    a-> 20b-> 30Program ended with exit code: 0
Run Code Online (Sandbox Code Playgroud)

c c++ scanf

2
推荐指数
1
解决办法
476
查看次数

标签 统计

c ×1

c++ ×1

scanf ×1