随笔分类 -  c语言学习

摘要:#include <stdio.h>#include <malloc.h>struct S{ int n; int arr[0];//未知大小-柔性数组成员-数组的大小是可以调整的};int main(){ struct S* ps = (struct S*)malloc(sizeof(struct 阅读全文
posted @ 2022-05-10 15:13 藏进夜里躲在光下 阅读(42) 评论(0) 推荐(0) 编辑
摘要:char* GerMemory(void){ char p[] = "hello world"; return p;} void Test(void){ char* str = NULL; str = GerMemory(); printf(str);} int main() { Test(); r 阅读全文
posted @ 2022-05-09 22:28 藏进夜里躲在光下 阅读(38) 评论(0) 推荐(0) 编辑
摘要://常见错误, //1.对NULL指针的解引用操作 //int* p = malloc(40); //*p = 10;//mallco开辟空间失败,-对NULL指针解引用,需要对p进行判断 //2.对动态开辟内存空间的越界访问 //3.对非动态开辟内存使用free释放 //4.使用free释放动态内 阅读全文
posted @ 2022-05-09 22:07 藏进夜里躲在光下 阅读(51) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> struct S{int a : 2; //a 只需要2个比特位int b : 5; // b 只需要5个比特位int c : 10;int d : 30; };int main(void){struct S s;printf("%d\n", sizeof(s) 阅读全文
posted @ 2022-04-29 17:50 藏进夜里躲在光下 阅读(29) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>struct S1{ char c1; int a; char c2;}; struct S2{ char c1; char c2; int a;}; struct S3 { double b;char c1;int a;}; struct S4 { double 阅读全文
posted @ 2022-04-29 13:23 藏进夜里躲在光下 阅读(27) 评论(0) 推荐(0) 编辑
摘要:1.strlen字符串求长度//遇到\0停止int len=strlen("abcdef");printf("%d\n,len); char arr[]={'a','b','c','d'};int len = strlen(arr); //随机值 遇到f后面的\0停止 1.1如果要自己写一个strl 阅读全文
posted @ 2022-04-24 19:14 藏进夜里躲在光下 阅读(34) 评论(0) 推荐(0) 编辑
摘要://判断一个字符串是否是逆序得来//在str1字符串后在添加一个str1,这样反转的字符串都可以在增加后的字符串找到abcdefabcdef、 #include <stdio.h>#include <string.h>#pragma warning(disable:4996) int is_left 阅读全文
posted @ 2022-04-18 18:51 藏进夜里躲在光下 阅读(63) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int FindNum(int arr[3][3], int k, int row, int col){ int x = 0; int y = col - 1; while (x <= col - 1 &&y >= 0) { if (arr[x][y]>k) / 阅读全文
posted @ 2022-04-18 16:00 藏进夜里躲在光下 阅读(38) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示