【问题标题】:Format specifier for scanning long unsigned int用于扫描 long unsigned int 的格式说明符
【发布时间】:2012-08-22 06:11:43
【问题描述】:

我正在尝试使用此代码 sn-p:-

将两个变量作为输入
unsigned int i;

unsigned long int j;

scanf("%u",i);

scanf("%lu",j);

但这会引起以下警告:-

警告:格式“%u”需要“unsigned int *”类型的参数,但参数 2 的类型为“unsigned int”[-Wformat] 警告:格式“%lu”需要“long unsigned int *”类型的参数,但参数 2 的类型为“long unsigned int”[-Wformat] 谁能向我解释这里发生了什么?

【问题讨论】:

    标签: c scanf


    【解决方案1】:

    您需要添加前导&,因为scanf指针 指向输出参数。否则,它不能写给他们。

    scanf("%lu", &i);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 2010-09-05
      • 2016-07-29
      • 1970-01-01
      • 2012-01-27
      相关资源
      最近更新 更多