【问题标题】:Incompatible arguments in c++c++ 中的参数不兼容
【发布时间】:2015-09-30 04:16:52
【问题描述】:

我确信这是一个非常基本的问题,但以下代码会产生错误 “错误:“int”类型的参数与“main.cpp”中“const char *”类型的参数不兼容,行:54,列:16

  for(int i = 0; i < 16; i ++){
pc.printf("Value at channel ");
pc.printf(i);
}

我想我明白它为什么这么说,但我该怎么办?

谢谢。

【问题讨论】:

  • 试试pc.printf("%d",i);
  • @George Edwards 这意味着 1)你应该最后阅读函数 pc.printf 的描述; 2) 为其提供正确的论据。

标签: c++ arguments


【解决方案1】:

你应该提供类型说明符

 for(int i = 0; i < 16; i ++){
    pc.printf("Value at channel ");
    pc.printf("%d",i);
    }

【讨论】:

  • 或者如果 c++11 std::string s = std::to_string(1);打印(s.c_str());
猜你喜欢
  • 2016-08-26
  • 2022-12-08
  • 1970-01-01
  • 2021-07-22
  • 1970-01-01
  • 1970-01-01
  • 2019-04-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多