随笔分类 - 编程语言
摘要:https://blog.csdn.net/Cashey1991/article/details/8333954 /* Function:函数指针数组 */ // 头文件 #include <stdio.h> #include <stdlib.h> #include <string.h> // 宏定
阅读全文
摘要:当声明一个字符串数组的时候,常常需要把它初始化为空串。总结起来有以下三种方式: (1) char str[10]=""; (2) char str[10]={'\0'}; (3) char str[10]; str[0]='\0'; 第(1)(2)种方式是将str数组的所有元素都初始化为'\0',而
阅读全文
摘要:第一版 #include <stdio.h> #include <stdlib.h> int main(void) { int A = 8; int num[] = {1,2,3,5}; // 打印数组大小的方法 printf("size is %d\n", sizeof(num) / sizeof
阅读全文
摘要:函数getopt()用来分析命令行参数,其函数原型和相关变量声明如下: extern char *optarg; extern int optind, // 初始化值为1,下一次调用getopt时,从optind存储的位置重新开始检查选项,也就是从下一个'-'的选项开始。 extern int op
阅读全文
摘要:命名规则 最短长度 & 最大信息量 每个单词首字母大写 避免数字编号 变量用大写字母隔开,宏定义、只读常量全部大写,下划线隔开 register 因寄存器数量有限,所以数据优化到寄存器的变量有限,而不是放在内存中。 因为变量不是放在内存中,所以不能用取址运算符 & 来获取register变量的地址。
阅读全文
摘要:这些函数包含在<stdlib.h>头文件中 malloc int* p = (int*)malloc(100 * sizeof(int));//最好能强制类型转换 malloc是申请空间 free是释放空间 他俩需要成对出现 calloc *void calloc( size_t num, size
阅读全文