【发布时间】:2012-09-15 07:52:25
【问题描述】:
我在 C 中的基本概念方面遇到了一些挑战。非常需要帮助。 我继续用代码的解释以及我想在那里提出的问题对代码进行注释。
void main (void)
{
printf("%x", (unsigned)((char) (0x0FF))); //I want to store just 0xFF;
/* Purpose of the next if-statement is to check if the unsigned char which is 255
* be the same as the unsigned int which is also 255. How come the console doesn't print
* out "sup"? Ideally it is supposed to print "sup" since 0xFF==0x000000FF.
*/
if(((unsigned)(char) (0x0FF))==((int)(0x000000FF)))
printf("%s","sup");
}
感谢您的帮助。
【问题讨论】:
-
基本概念 #1:main() 应该返回 int。
-
这里的问题似乎有些混乱。你没有变量。
-
@stefan:
unsigned == unsigned int -
由于此代码中没有变量并且没有存储任何内容,那么是的,您在真正的基本概念方面遇到了问题。
标签: c variables types char int