自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 Linux自动输入账号密码脚本 使用expect

Linux自动输入账号密码 使用expect

2022-08-13 00:16:32 630

原创 C++ prime第五版 习题 第三章

3.2Write a program to read the standard input a line at a time.Modify your program to read a word at a time.#include<iostream>#include<string>using namespace std;int main(void){ string str_in; while(getline(cin,str_in))

2022-05-01 20:04:35 1628

原创 C语言实现堆排序

void heapsort(int n, int ar[]){ int i; int heap_size = n; build_max_heap(n,ar); for(i=n-1;i>=1;i--) { int temp; temp = ar[0]; ar[0] =ar[i]; ar[i] =

2022-03-15 17:48:47 714

原创 希尔排序 --C语言实现

//增量gap: length/2void shellsort(int n, int ar[]){ int gap,i,j; for(gap=n/2;gap>=1;gap/=2) for(i=0;i<n;i++) /* i为希尔排序的第一个元素 */ insertion_sort_sh(n,ar,i,gap);}void insertion_sort_sh(int n,int

2022-03-13 16:50:45 1675

原创 时间与日期例程

获取日历时间time()获取日历时间 (日历时间:自UTC以来经过的秒数。用长整型time_t表示。)#include<time.h>time_t time(time_t *calptr);成功时返回时间值,出错时返回-1.若参数非空,时间值也会存入calptr所指向的单元.clock_gettime()获取指定时钟的时间。#include<sys/time.h>int clock_gettime(clockid_t clock_id, struct ti.

2022-03-11 16:48:09 294

原创 Linux文件状态信息与权限

目录fstat、stat、lstataccess和faccessatumask系统调用chmod、fchmod和fchmodetchown、fchown、fchownat、和lchownfstat、stat、lstat获取文件状态信息(status)。原型#include<unistd.h>#include<sys/stat.h>#include<sys/types.h>int fstat(int fildes, struct stat *buf);

2022-02-12 16:51:39 509

原创 Linux底层文件访问

目录write系统调用read系统调用open系统调用close系统调用lseek系统调用write系统调用把buf的前nbytes字节写出至文件fildes.原型#include <unistd.h>size_t write(int fildes, const void *buf, size_t nbytes);返回值返回实际写出的字节数,出错时返回-1并设置errno.read系统调用从文件fildes读入nbytes字节的数据,并放入buf.原型#include

2022-02-12 16:50:34 127

原创 C语言<string.h> --常用字符串函数

目录1. strcpy()、strncpy()2. strcat()、strncat()3. strcmp()、strncmp()4. strlen()1. strcpy()、strncpy()char *strcpy(char * restrict s1, const char * restrict s2);char *strncpy(char * restrict s1, const char * restrict s2, size_t n);strcpy()将字符串s2拷贝(copy)至s

2022-02-12 16:49:46 418

原创 标准I/O库 --字符(串)I/O

目录fgetc()、getc()、getchar()fputc()、putc()、putchar()fgets()、fputs()fgetc()、getc()、getchar()fgetc()从文件流获取下一个字符。函数原型int fgetc(FILE *stream);返回值返回字符的整数形式;到达文件尾或出现错误时,返回EOF。(用feof()和ferror()区分两种情况)。getc()类似fgetc(),但getc()可能被实现为宏。因此:1.getc()参数不能有

2022-02-12 16:48:38 63

原创 C语言 --错误处理

目录errnostrerror()perror()文件流错误ferror()feof()clearerr()errno#include<errno.h>extern int errno;errno取值含义EPERM操作不允许(permitted)ENOENT文件或目录不存在(no entries)EINTR系统调用被中断(interrupted)EIOI/O错误EBUSY设备或资源忙(busy)EEXIST文件存在(exis

2022-02-02 21:03:37 1229

原创 标准I/O库 --文件I/O

fopen()函数原型FILE *fopen(const char *filename, const char *mode);modemode说明r(b)以读模式打开。w(b)以写模式打开,并把文件长度截为零。a(b)以写模式打开,追加新内容在文件尾。filenamefclose()fread()fwrite()fflush()fssek()...

2022-02-01 11:42:02 622

原创 标准I/O库 --格式化输出(printf族)

目录printf族printf族的变体printf族函数原型#include <stdio.h>int printf(const char *restrict format, ...); //输出至标准输出 int fprintf(FILE *restrict fp, const char *restrict format, ...); //通过文件流输出至文件 int dprintf(int fd, const char *restrict format, ...); //通过文

2022-01-28 21:41:13 753

原创 C语言 static关键字

目录1. 对于文件作用域变量,用static区分是外部链接还是内部链接:2. 对于块作用域变量,static使其具有静态存储期:3. 用static创建静态函数:1. 对于文件作用域变量,用static区分是外部链接还是内部链接:int giants = 5; //文件作用域,外部链接static int dodgers = 3; //文件作用域,内部链接int main(){...}2. 对于块作用域变量,static使其具有静态存储期:void more(int number)

2022-01-27 21:38:10 256

原创 Linux 扫描目录

目录扫描目录扫描目录#include<dirent.h>DIR *opendir(const char *pathname);DIR *fdopendir(int fd);struct dirent *readdir(DIR *dp);void rewinddir(DIR *dp);int closedir(DIR *dp);long telldir(DIR *dp);void seekdir(DIR *dp,long loc); Name 参

2022-01-27 17:52:08 1193

原创 Linux用户信息

目录getuid()和getlogin()getpwuid()和getpwnam()passwd结构getuid()和getlogin()原型#include<unistd.h>uid_t getuid(void);char *login(void);参数void返回值getuid()返回程序关联的UID;getlogin()返回当前用户登录名。getpwuid()和getpwnam()原型#include<pwd.h>struct passwd *

2022-01-27 13:20:03 1387

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除