Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C语言中读取错误消息(运行时错误166:36)?_C_Runtime Error_Cs50 - Fatal编程技术网

如何在C语言中读取错误消息(运行时错误166:36)?

如何在C语言中读取错误消息(运行时错误166:36)?,c,runtime-error,cs50,C,Runtime Error,Cs50,我有两个问题:36在错误消息中是什么意思,这些代码行有什么问题 我的程序可以编译,但运行时会收到运行时错误消息。显然,它试图将值256分配给位图颜色通道,该通道的上限应为255。以下是错误消息: helpers.c:166:36: runtime error: 256 is outside the range of representable values of type 'unsigned char' 166是问题所在,但36意味着什么?我要通过这个循环数十万次,我如何调试它? 另一件事是,

我有两个问题:36在错误消息中是什么意思,这些代码行有什么问题

我的程序可以编译,但运行时会收到运行时错误消息。显然,它试图将值256分配给位图颜色通道,该通道的上限应为255。以下是错误消息:

helpers.c:166:36: runtime error: 256 is outside the range of representable values of type 'unsigned char'
166是问题所在,但36意味着什么?我要通过这个循环数十万次,我如何调试它? 另一件事是,我不明白为什么它不会注册255;这是我的密码:

if (round(sqrt(xg * xg + yg * yg)) > 255)
{
    temp[i][j].rgbtGreen = 255;
}
else
{
    temp[i][j].rgbtGreen = round(sqrt(xg * xg + yg * yg));
}
最后一行是166

我会感谢你给我带来的光明。
Al.

166:36,第166行,第36列(第166行的第36个字符)。这将为您提供线路上发生问题的大致位置,以帮助您提供提示。避免重复计算
unsigned char tmp=round(sqrt(xg*xg+yg*yg)
并用tmp inside condition和else语句替换它xg和yg是什么数据类型?感谢帮助。xg和yg是整数。没有人记得存在。166:36,第166行,第36列(第166行的第36个字符)。这将为您提供行中出现问题的大致位置,以帮助提供提示。避免进行两次计算。
unsigned char tmp=round(sqrt(xg*xg+yg*yg)
并将其替换为tmp inside condition和else语句xg和yg是什么数据类型?感谢您的帮助。xg和yg是整数。没有人记得存在。