好.这是我遇到的最奇怪的错误之一.我的代码中有这两行
int id=i*2000*512+512*row+column;
if (id==1){printf("This is output %f %f %f %i \n",entire_red[id],entire_green[id],entire_blue[id],id);}
Run Code Online (Sandbox Code Playgroud)
它给了我输出
这是输出0.000000 0.000000 0.000000 109456488.
我不知道发生了什么!
该%f格式说明需要一个double(float隐式转换为double可变参数的函数).如果variable_red等不是float或double变量,那么printf将错误地处理参数,这可以解释为什么id整数打印不正确.
试试这个:
if (id==1)
printf("This is output %f %f %f %i\n", (double)entire_red[id],(double)entire_green[id],(double)entire_blue[id],id);
Run Code Online (Sandbox Code Playgroud)
另外,确保使用正确的格式说明的entire_red,entire_green和entire_blue变量.