12 2019 档案
摘要:char *p = "abc" //p1 指向的是字符常量,字符常量的值不能修改
阅读全文
摘要:实例 #include <string.h> #include <stdio.h> int main () { void * p; int a = 10; p = &a; printf("%d\n", *((int *)p)); return(0); }
阅读全文
摘要:描述 C 库函数 int atoi(const char *str) 把参数 str 所指向的字符串转换为一个整数(类型为 int 型)。 声明 下面是 atoi() 函数的声明。 int atoi(const char *str) 参数 str -- 要转换为整数的字符串。 返回值 该函数返回转换
阅读全文
摘要:描述 C 库函数 char *strtok(char *str, const char *delim) 分解字符串 str 为一组字符串,delim 为分隔符。 声明 下面是 strtok() 函数的声明。 char *strtok(char *str, const char *delim) 参数
阅读全文
摘要:描述 super() 函数是用于调用父类(超类)的一个方法。 super 是用来解决多重继承问题的,直接用类名调用父类方法在使用单继承的时候没问题,但是如果使用多继承,会涉及到查找顺序(MRO)、重复调用(钻石继承)等种种问题。 MRO 就是类的方法解析顺序表, 其实也就是继承父类方法时的顺序表。
阅读全文
摘要:描述 C 库函数 char *strchr(const char *str, int c) 在参数 str 所指向的字符串中搜索第一次出现字符 c(一个无符号字符)的位置。该函数返回在字符串 str 中第一次出现字符 c 的位置,如果未找到该字符则返回 NULL。 实例 #include <stdi
阅读全文
摘要:描述 C 库函数 int sscanf(const char *str, const char *format, ...) 从字符串读取格式化输入。 实例 #include <stdio.h> #include <stdlib.h> #include <string.h> int main() {
阅读全文
摘要:描述 C 库函数 char *fgets(char *str, int n, FILE *stream) 从指定的流 stream 读取一行,并把它存储在 str 所指向的字符串内。当读取 (n-1) 个字符时,或者读取到换行符时,或者到达文件末尾时,它会停止,具体视情况而定。 实例 #includ
阅读全文
摘要:描述 C 库函数 char *gets(char *str) 从标准输入 stdin 读取一行,并把它存储在 str 所指向的字符串中。当读取到换行符时,或者到达文件末尾时,它会停止,具体视情况而定。 实例 #include <stdio.h> int main() { char str[50];
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> int main() { srand(100); //设置种子,种子一样,每次启动程序时生成的数也一样 int i; int num; for(i=0; i<10; i++) { num = rand(); printf(
阅读全文
摘要:使用示例: #include <stdio.h> int main () { /* 局部变量定义 */ int a = 10; /* do 循环执行 */ LOOP:do { if( a == 15) { /* 跳过迭代 */ a = a + 1; goto LOOP; } printf("a 的值
阅读全文
摘要:int main() { int a = 10; int b = 20; int c = a > b ? a : b; printf("%d\n", c); return 0; }
阅读全文
摘要:作用 防止编译器优化变量 如对于下面这段行代码: int main() { int a; a = 1; a = 2; a = 3; return 0; } 编译器可能回跳过前面两句赋值,直接执行 a = 3
阅读全文
摘要:十进制:以正常数字1-9开头,如:123 八进制:以数字0开头,如:0123 十六进制:以数字0x开头,如:0x123 二进制:c 语言不能直接书写二进制数 printf打印: 十进制:%d 八进制:%o 十六进制:%x
阅读全文
摘要:功能 调用一个外部程序(命令都是 C 写的可执行程序) 使用示例 system('ls -alh')
阅读全文
摘要:编译 c 代码: gcc file.c gcc file.c -o outputname
阅读全文
摘要:进程间通信常用的4种方法 1. 管道:简单 2. 信号:系统开销小 3. 共享映射区:有无血缘关系的进程间通信都可以 4. 本地套接字:稳定 管道 匿名管道pipe 适用于有血缘关系的进程间通信 pipe函数 #include<unistd.h> int pipe(int filedes[2]);
阅读全文
摘要:编译安装(复杂麻烦) RPM安装 RPM介绍 Redhat提供了rpm管理体系已经编译的软件包:针对不同的平台系统编译目标软件包操作系统维护安装信息rpm 只能安装已经下载到本地机器上的rpm 包,且不能自动处理包与包之间的依赖问题 rpm安装 rpm -ivh filename (i表示insta
阅读全文