![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言必刷题
weixin_46060711
c/c++
展开
-
const常量可不可以被修改
1,使用 C++编译器,“偷偷”修改 const 常量,无效,但是也不报错2,使用 C 语言编译器,可以“偷偷”修改 const 常量。原创 2022-11-29 23:13:26 · 405 阅读 · 0 评论 -
关于指针转换,指针加减的深入理解
代码如下:#include <stdio.h>int main(void) { int a[5] = {1, 2, 3, 4, 5); int *pstr1 = (int*)(&a + 1); int *pstr2 = (int*)((int)a + 1); printf("%x, %x\n", *pstr1[-1], *pstr2); return 0;}输出结果为:5 2000005可以明白怎么得到的,但是为什么会出现200000?请看图!(地址为小端原创 2021-12-26 21:27:50 · 244 阅读 · 0 评论 -
关于char类型的值的周期
#include <stdio.h>#incldue <string.h>#incldue <stdlib.h>int main(void) { char a[1000]; for(int i=0; i<1000; i++) { //-1 -2 -3 -4 -5 -7 ... -126 -127 -128 127 126 125 ... 2 1 0 a[i] = -1 - i; } printf("%d\n", strlen(a));原创 2021-12-26 20:52:24 · 224 阅读 · 0 评论 -
无字符串结束符,字符串拷贝越界
无字符串结束符,字符串拷贝越界:#include <stdio.h>#include <string.h>#include <stdlib.h>int main(void) { char str1[10], str2[10]; for(int i=0; i<10; i++) str1[i] = 'a'; strcpy(str2, str1); printf("%s\n", str2); system("pause"); retu原创 2021-12-26 20:34:39 · 188 阅读 · 0 评论 -
有符号数与无符号数相加减结果为无符号数
有符号数与无符号数相加减:#include <stdio.h>#include <stdlib.h>int main(void) { unsigned int a = 6; if(a-20 >= 6) { printf(">=6"); }else { printf("<=6"); } system("pause"); return 0;}输出结果为:原创 2021-12-26 20:26:07 · 634 阅读 · 0 评论