第3章 文件操作

fflush 函数:

 int fflush(FILE *stream);

fseek

fgetc getc getchar

fputc putc putchar

fgets gets

printf fprintf sprintf (for file string) %g double %% output "%"

  %-10s ,%*s following 5,"string"

scanf fscanf ssanf (the purpose of inserting a blank is for ingnoring blank characters)

  %[]:读取一个字符集合

 

other functions:

  fgetpos fsetpos ftell rewind freopen setvbuf remove

 

文件和目录的维护

  chmod chown

  unlink link symlink

  mkdir rmdir

  chdir getcwd

 

扫描目录

  opendir closedir

  readdir  telldir  seekdir 

  include <sys/types.h> .<dirent.h>

错误处理:

 strerror perror

/proc文件系统:

/proc/cpuinfo  meminfo  version  //cat to view

/proc/net/sockstat

/proc/sys/fs/file-max  //edit max number of open file in same time :  echo "80000" >/proc/sys/fs/file-max

高级管理:

fcntl:

fcntl(filedes,F_DUPFD,newfd)

fcntl(fd,F_GETFD) 

fcntl(fd,F_SETFD,flags)  //only for seting flag FD_CLOEXEC

 

mmap: 建立一段可以被两个或多个程序读写的内容

msync: synchronize mapping file

munmap: release memory

 

posted @ 2016-07-02 05:55  孤灯下的守护者  阅读(110)  评论(0编辑  收藏  举报