随笔分类 -  C语言

摘要:起因:由于在《C与指针》153页看到这么一个定义 char *message2 = "Hello"; 这种定义早就想尝试了,在看到书上这么写后,就进行了如下代码 #include <iostream> #include <cstring> #include <cstdio> using namesp 阅读全文
posted @ 2020-08-20 12:55 阿拉灯神丁0 阅读(327) 评论(0) 推荐(0)
摘要:1、两数相换 1 #include <stdio.h> 2 3 void exchang(int *, int *); 4 5 6 int main() 7 { 8 int a, b; 9 scanf("%d,%d",&a,&b); 10 printf("交换前:a = %d, b = %d\n", 阅读全文
posted @ 2020-08-17 13:08 阿拉灯神丁0 阅读(138) 评论(0) 推荐(0)
摘要: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 阅读(282) 评论(0) 推荐(0)
摘要:在循环中使用scanf的注意事项: 如果输入的格式不正确,则在后面的循环中会跳过scanf(),从而变成死循环,或者无法得到想要的结果; 如 #include <stdio.h> int main() { unsigned int year; char flag = 0, m; printf("请输 阅读全文
posted @ 2020-08-15 15:42 阿拉灯神丁0 阅读(450) 评论(0) 推荐(0)
摘要:一些声明具有external属性 一些声明具有internal属性 阅读全文
posted @ 2020-07-09 11:41 阿拉灯神丁0 阅读(305) 评论(0) 推荐(0)