#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
unsigned char n;
int total;
n = 50;
while(n-->0)
{
total += n;
}
return 0;
}
代码如上
变量n是无符号字符,当n为0时,进入循环,后执行n--,还是大于0,通过dev++调试,显示变成255,但是没进入循环,程序结束了,为什么呢?