摘要: C语言:fgets和fgetc函数读取文件 1、fgetc 是 file get char 的缩写,意思是从指定的文件中读取一个字符。 fgetc() reads the next character from stream and returns it as an unsigned char ca 阅读全文
posted @ 2023-02-10 15:26 opensmarty 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 一、strstr()函数用来检索子串在字符串中首次出现的位置,其原型为: char *strstr( char *str, char * substr ); 1、头文件:#include <string.h> 2、参数说明:str为要检索的字符串,substr为要检索的子串。 3、返回值:返回字符串 阅读全文
posted @ 2023-02-10 15:22 opensmarty 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 一、access()函数用来判断用户是否具有访问某个文件的权限(或判断某个文件是否存在). 二、需要包含#include<unistd.h> 三、参数和返回值 int access(const char *pathname,int mode) 参数: pathname:表示要测试的文件的路径 mod 阅读全文
posted @ 2023-02-10 15:01 opensmarty 阅读(502) 评论(0) 推荐(0) 编辑
摘要: C语言可变参数个数的函数学习 一、学习测试C代码 #include <stdio.h> #include <stdarg.h> void fixed_args_func(int a, double b, char *c,int d) { printf("a = 0x%p\n", &a); print 阅读全文
posted @ 2023-02-10 14:36 opensmarty 阅读(31) 评论(0) 推荐(0) 编辑
摘要: C语言宏定义中#符号和##的妙用 一、 宏定义可以包含两个专用的运算符:#和##。编译器不会识别这两个运算符,他们会预处理时被执行。 二、#运算符的用法 (1)#运算符用在预编译时期,用于将宏参数转换为字符串,即是加上双引号。 (2)测试代码 #include <stdio.h> #define P 阅读全文
posted @ 2023-02-10 14:34 opensmarty 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 一、大小端简介 大小端是计算机存储的两种方式。 小端表示法(Little-endian): 所谓的小端模式,是指数据的高位保存在内存的高地址中,而数据的低位保存在内存的低地址中,这种存储模式将地址的高低和数据位权有效地结合起来,高地址部分权值高,低地址部分权值低,和我们的逻辑方法一致。如: 16bi 阅读全文
posted @ 2023-02-10 14:24 opensmarty 阅读(197) 评论(0) 推荐(0) 编辑
摘要: C语言#error #line #pragma预处理学习 一、#error 的用法 (1)#error 是一种预编译器指示字,用于生成一个编译错误消息 (2)用法:#error message //注意:message 不需要用双引号包围 (3)#error 编译指示字用于自定义程序员特有的编译错误 阅读全文
posted @ 2023-02-10 13:50 opensmarty 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-02-10 11:23 opensmarty 阅读(11) 评论(0) 推荐(0) 编辑
摘要: gcc 进行 c 语言编译分为四个步骤: 1.预处理,生成预编译文件(.i 文件): gcc –E hello.c –o hello.i 2.编译,生成汇编代码(.s 文件): gcc –S hello.i –o hello.s 3.汇编,生成目标文件(.o 文件): gcc –c hello.s 阅读全文
posted @ 2023-02-10 11:11 opensmarty 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 一、函数原型 snprintf(),为函数原型int snprintf(char *str, size_t size, const char *format, ...)。 二、函数介绍 将可变个参数(...)按照format格式化成字符串,然后将其复制到str中(1) 如果格式化后的字符串长度 < 阅读全文
posted @ 2023-02-10 10:40 opensmarty 阅读(227) 评论(0) 推荐(0) 编辑