c - While 循环的输出

标签 c while-loop

如果short int为2字节,则下面的程序中的while循环会执行多少次?

main()
{
int j = 1;
while(j <= 255);
{
    printf("%d",j); 
    j++;
}
return 0;
}

我认为应该是 255 次,但这是不正确的。谁能告诉我为什么?

最佳答案

while 行末尾有一个分号。 while 循环由语句 ; 组成,“无限”执行多次。

关于c - While 循环的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30923475/

相关文章:

c - -无法在区域 DSEG 的内部 RAM 中获取连续字节

c - 在 C 中,我如何只接受某些字符串并继续要求用户输入直到输入有效输入?

java - 在Java中的 `break`循环中使用 `while`语句有什么问题?

VBA如何获取下一个单元格地址

java - Java 中的逻辑和循环问题

C: unsigned char * bytes 数组将元素复制到其他 unsigned char * 数组

c - UNIX TCP/IP :read: Transport endpoint is not connected read: Transport endpoint is not connected

c - malloc 中的 Sigsegv

c - AVR 中断配置

while循环中的php sum变量