- 博客(16)
- 收藏
- 关注
原创 linux系统下ls -r命令的简单实现(补充部分)
void file_info_list_clear(file_info_list*);void print(file_info_list *beg, int num){ for (int i = 0; i < num; ++i) printf("\t"); printf(".\n"); for (int i = 0; i < num; ++i) printf("\t");
2021-01-09 13:56:41 980 1
原创 linux系统下ls -r命令的简单实现(C语言版)
// lsr.h#ifndef LSR#define LSR#include <stdio.h> // printf()#include <unistd.h> // getcwd()#include <string.h> // strlen() strcpy() strcat() memset()#include <stdlib.h> // exit() malloc() free() atexit()#include <dir
2021-01-08 23:06:22 1343
原创 ls -al命令的简单实现(C语言版)
#include <stdio.h> // printf()#include <string.h> // strcmp() strcpy() memset()#include <stdlib.h> // malloc() free()#include <dirent.h> // opendir() closedir() readdir()#include <unistd.h> // getcwd();#include
2021-01-06 22:12:00 745
原创 Linux系统下 ls 命令的简答实现
// ls.h#include <stdio.h> // printf()#include <string.h> // strcmp() strcpy() memset()#include <stdlib.h> // malloc() free()#include <dirent.h> // opendir() closedir() readdir()#include <unistd.h> // getcwd();
2021-01-05 21:23:18 221
原创 我们的程序为什么需要头文件
什么是源文件、什么是头文件我所见到的最好的答案:通常,在一个 C++ 程序中,只包含两类文件―― .cpp 文件和 .h 文件。其中,.cpp 文件被称作 C++ 源文件,里面放的都是 C++ 的源代码;而 .h 文件则被称作 C++ 头文件,里面放的也是 C++ 的源代码。个人理解:我们为一个工程或项目所写的所有程序文件都可以被称为源文件。其中源文件包括头文件(C语言的.h文件 \ C+...
2019-12-08 23:38:43 2234 1
原创 c语言库函数strcat源码实现
#include <string.h>#undef strcat#ifndef STRCAT#define STRCAT strcat#endifchar *STRCAT (char *dest, const char *src){ strcpy (dest + strlen (dest), src); return dest;}...
2019-12-04 23:35:29 1582
原创 hello.i 预处理文件
预处理hello.i 预处理文件是 hello.c C语言程序文件预处理之后的文件。预处理是编译过程的第一个阶段。预处理器(cpp)根据以字节#开头的命令,修改原始的C程序。比如hello.c中第1行的 #include <stdio.h> 命令告诉预处理器读取系统头文件stdio.h的内容,并把它直接插入到程序文本中。结果就得到了另一个C程序,通常是以 .i 作为文件扩展名。/...
2019-12-04 18:55:12 2212 1
原创 c语言库函数strcmp源码实现
#include <string.h>#undef strcmp#ifndef STRCMP#define STRCMP strcmp#endifintSTRCMP (const char *p1, const char *p2){ const unsigned char *s1 = (const unsigned char *) p1; ...
2019-12-04 17:34:45 5366
原创 hello程序的生命周期
# 1 "hello.c"......extern int printf (const char *__restrict __format, ...);......# 2 "hello.c" 2# 3 "hello.c"intmain (void){ printf("hello world!"); return 0;} .file "hello.c...
2019-12-04 11:42:02 514
原创 c语言库函数strchr源码实现
#include <string.h>#include <stdlib.h>#undef strchr#ifndef STRCHR#define STRCHR strchr#endifchar *STRCHR (const char *s, int c_in){ const unsigned char *char_ptr; ...
2019-12-02 23:15:38 1406
原创 c语言库函数strlen源码实现
#include <string.h>#include <stdlib.h>#undef strlen#ifndef strlen#ifndef STRLEN#define STRLEN strlen#endifsize_tSTRLEN (const char *str){ const char *char_ptr; ...
2019-11-25 20:30:36 2712
原创 C语言打包解包程序2
C语言打包解包程序这个程序接着我的上一篇打包解包程序,对上一篇的程序进行了改进,把冗长的打包程序分解成了几个小程序,把匹配打包与全部打包融合在了一起,算是对上一篇程序的改进吧。头文件pack.h#define MAX_PATH 128#define MAX_NAME 32typedef struct file { char name[MAX_NAME]; ...
2019-11-12 14:24:52 1091
原创 C语言打包解包程序
C语言打包解包程序本程序是一个打包解包程序,提供了打包解包文件夹,查看打包文件信息,解包等功能。如果需要打包的文件夹中存在文件夹,会递归打包,解包时也会递归解包,保证原样还原。头文件及main函数#include<stdio.h>#include<io.h>#include<direct.h>#include<stdlib.h>#in...
2019-11-01 22:47:12 4631 2
原创 C/C++static的巧妙用法
C/C++static的巧妙用法学过C或者C++的想必都知道static定义静态变量。但是通过书中的例题实在是想不明白它到底有什么用途,本编文章将通过一个例子来介绍static的巧妙用法,让你对static定义的静态变量用更深层的认识。首先先来复习一下什么是静态变量(会的可以直接略过)静态变量的类型说明符是static。 静态变量当然是属于静态存储方式,但是属于静态存储方式的量不一定就是...
2019-06-08 01:30:32 289 1
原创 C++STL容器共通操作之初始化(Initialization)
**C++STL容器共通操作之初始化(Initialization)**c++stl每个容器都提供了一个default构造函数,一个copy构造函数和一个析构函数。你可以以某个已知区间的内容作为容器初始值,自c++11起你也可以指定一个初值列(initialization list)。操作:ContType c : Default构造函数,建立一个未含任何元素的空容器ContT...
2019-05-09 23:52:43 928
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人