随笔分类 -  C基础

摘要:出处 https://www.cnblogs.com/dolphin0520/archive/2011/09/17/2179466.html 结构体在内存中存储位置并不是按照各自的元素占的空间大小顺序放置的,它有一定的规律,这个规律就是结构体成员内存对齐的内容。 需要内存对齐的原因: 1) 平台限制 阅读全文
posted @ 2021-04-05 15:56 王清河 阅读(121) 评论(0) 推荐(0) 编辑
摘要:在C/C++程序中,main函数结束,会有一个步骤去调用 atexit 注册的函数 #include<cstdio> #include<cstdlib> void func1() { printf("The process is done...\n"); } void func2() { print 阅读全文
posted @ 2021-04-05 12:14 王清河 阅读(605) 评论(0) 推荐(0) 编辑
摘要:今天遇到了一个紧急问题,需要把时间戳转成一个int型,就有了这个小demo #include<cstdio> #include<ctime> #include<cstdlib> int main() { time_t t; time(&t); t = t + 8 * 3600; tm *tt = g 阅读全文
posted @ 2020-02-21 14:48 王清河 阅读(4102) 评论(0) 推荐(0) 编辑
摘要:python调用C库时参数太多,约定传json格式字符串,C解析 #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct __Json_ { int byExposureModeSet; int byFocusMo 阅读全文
posted @ 2019-12-19 15:57 王清河 阅读(4107) 评论(0) 推荐(0) 编辑
摘要:函数介绍: strcasecmp用忽略大小写比较字符串.,通过strcasecmp函数可以指定每个字符串用于比较的字符数,strncasecmp用来比较参数s1和s2字符串前n个字符,比较时会自动忽略大小写的差异。 strcasecmp函数是二进制且对大小写不敏感。此函数只在Linux中提供,相当于 阅读全文
posted @ 2019-12-17 15:51 王清河 阅读(5384) 评论(0) 推荐(0) 编辑
摘要:函数描述: 检索字符串 str1 开头连续有几个字符都不含字符串 str2 中的字符。 函数声明: #include<string.h> size_t strcspn(const char* str1, const char *str2); 参数: str1:要被检索的字符串 str2:该字符串包含 阅读全文
posted @ 2019-12-17 15:36 王清河 阅读(341) 评论(0) 推荐(0) 编辑
摘要:链表创建删除插入查找销毁操作 #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct Node { int data; struct Node *next; }SLIST; SLIST *SList_Create( 阅读全文
posted @ 2019-12-08 13:33 王清河 阅读(268) 评论(0) 推荐(0) 编辑
摘要:/* float.c */ #include<stdio.h> #include<string.h> int main() { FILE *fp = fopen("Data.txt","w+"); float f[3][5] = {{-3.41, 5.63, 6, 7.8, 1.3}, {4.5 , 阅读全文
posted @ 2019-11-26 08:58 王清河 阅读(721) 评论(0) 推荐(0) 编辑
摘要:配置文件读写系统方法和测试函数 #include"readConfig.h" #define CFGNAME "./test.txt" void mymenu() { printf(" \n"); printf("1 Test Write Config file\n"); printf("2 Tes 阅读全文
posted @ 2019-11-23 22:56 王清河 阅读(355) 评论(0) 推荐(0) 编辑
摘要:函数原型: #include <unistd.h> int symlink(const char * oldpath, const char * newpath); 函数说明: symlink()以参数newpath 指定的名称来建立一个新的连接(符号连接)到参数oldpath 所指定的已存在文件. 阅读全文
posted @ 2019-11-11 14:34 王清河 阅读(1594) 评论(0) 推荐(0) 编辑
摘要:函数原型; #include<unistd.h> ssize_t readlink(const char *path, char *buf, size_t bufsiz); 函数说明: readlink()会将参数path的符号链接内容存储到参数buf所指的内存空间,返回的内容不是以\000作字符串 阅读全文
posted @ 2019-11-11 14:21 王清河 阅读(14170) 评论(2) 推荐(1) 编辑
摘要:函数原型: include<stdlib.h> char *getenv(char *envvar); 函数说明: getenv()用来取得参数envvar环境变量的内容。参数envvar为环境变量的名称,如果该变量存在则会返回指向该内容的指针。环境变量的格式为envvar=value。getenv 阅读全文
posted @ 2019-11-11 14:17 王清河 阅读(561) 评论(0) 推荐(0) 编辑
摘要:按照字符读取和写入 #include<stdio.h> #include<string.h> #include<stdlib.h> int fputc_func(char *filename) { int i = 0; FILE *fp = NULL; char buf[64] = "this is 阅读全文
posted @ 2019-11-10 21:39 王清河 阅读(1141) 评论(0) 推荐(0) 编辑
摘要:#include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct Teacher { char name[64]; int age; char *pname2; }teacher; /* 编译器的=号操作会把指针变量的值,从 阅读全文
posted @ 2019-11-09 20:50 王清河 阅读(244) 评论(0) 推荐(0) 编辑
摘要:/*** point_practice.c ***/ #include<stdio.h> #include<string.h> #include<stdlib.h> int sort( char **myp1 /*in*/, int num1, char (*myp2)[30], int num2, 阅读全文
posted @ 2019-11-09 20:48 王清河 阅读(203) 评论(0) 推荐(0) 编辑
摘要:index函数 函数定义: #include<strings.h> char *index(const char *s, int c); 函数说明: 找出参数s字符串中第一个出现参数c的地址,然后将该字符串出现的地址返回。字符串结束字符(NULL)也视为字符串的一部分。 返回值: 如果找到指定的字符 阅读全文
posted @ 2019-11-08 17:04 王清河 阅读(942) 评论(0) 推荐(0) 编辑
摘要:结构体中含有二级指针的内存分配和释放 #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct Teacher { char name[64]; char *alisname; char **stuname; int 阅读全文
posted @ 2019-11-02 20:01 王清河 阅读(242) 评论(0) 推荐(0) 编辑
摘要:结构体中含有一维指针的内存分配和释放 阅读全文
posted @ 2019-11-02 19:59 王清河 阅读(249) 评论(0) 推荐(0) 编辑
摘要:结构体值栈空间内存模型 结构体堆空间内存模型 阅读全文
posted @ 2019-11-01 23:05 王清河 阅读(312) 评论(0) 推荐(0) 编辑
摘要:在一个函数中传进一个二位数组,打印的第一种方式是求出字符串个数,然后再遍历打印。 除此之外,还可以在传入的二维数组的最后放入一个结束标志,如一位数组的最后’\0’一样,来表示二位数组的结束标识。 除了最后放”\0”以外,0和NULL也是可以的。 实际上,\0就是转义的0,两者是等价的。 而且在std 阅读全文
posted @ 2019-10-27 20:07 王清河 阅读(246) 评论(0) 推荐(0) 编辑

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