摘要: https://wiki.sei.cmu.edu/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow 阅读全文
posted @ 2020-08-15 17:21 阿拉灯神丁0 阅读(236) 评论(0) 推荐(0)
摘要: int m, n; unsigned int s; s = m + n 这里有两个错误 1)有符号转无符号 2)整型溢出 这里主要说有符号转无符号 一般的都认为 m , n都强制转换为 无符号数,这是错误的!!! 这里 m, n依然是无符号的,m + n的结果也是无符号的,然后再把这个结果转成 un 阅读全文
posted @ 2020-08-15 16:43 阿拉灯神丁0 阅读(277) 评论(0) 推荐(0)
摘要: 在循环中使用scanf的注意事项: 如果输入的格式不正确,则在后面的循环中会跳过scanf(),从而变成死循环,或者无法得到想要的结果; 如 #include <stdio.h> int main() { unsigned int year; char flag = 0, m; printf("请输 阅读全文
posted @ 2020-08-15 15:42 阿拉灯神丁0 阅读(434) 评论(0) 推荐(0)