目录函数

一、

1.getpuwid:根据用户id到/etc/passwd文件下解析获得结构体息 struct passwd *getpwuid(uid_t uid)

返回值:成功返回id对应用户的信息            失败返回NULL

2.getgrgid:根据gid到/etc/group文件中解析组信息   struct group *getgrgid(gid_t gid)

成功返回组信息          失败返回NULL

3.time:获得1970年到现在的秒数      成功返回1970年到现在的秒数      失败返回-1

        time_t time(time_t *t);
        time_t tm;
        time(&tm)

4.ctime:将时间秒数转化为字符串   char *ctime(const time_t *timep)

timep:保存时间空间的地址     成功返回获得时间字符串的首地址       失败返回NULL 

5.localtime:将一个秒数转化成日历时间     struct tm *localtime(const time_t *timep)

成功返回保存日历时间结构体的指针           失败返回NULL

二、链接文件

1.file.txt -> hello.c       软链接文件、符号链接文件、硬链接文件

命令行:ln -s 123 softlink 快捷方式

2.symlink:int  symlink(const  char  *oldpath, const char *newpath)

        创建一个链接向oldpath文件的新符号链接文件

       oldpath:被链接向的文件的路径           newpath:新符号链接文件

     成功返回0    失败返回-1

3.remove:int remove(const char *pathname)   删除一个文件

      成功 返回0                 失败 返回-1

4.rename:int  rename(const  char  *oldpath,  const char *newpath)

       将一个老的路径名改为新的路径名   成功返回0     失败返回-1

5.link ln 1 2 :int  link(const char *oldpath, const char *newpath)创建一个硬链接文件(ll -i)

        成功返回0        失败返回-1

6.truncate:修剪文件到指定长度 int truncate(const char *path,off_t length);

   path文件名,length 修剪长度         成功返回0   失败返回-1

三、报错相关函数

1.perror: 打印s字符串和errno对应的错误信息   void perror(const char *s)

          s 要打印在终端上的出错信息          返回值:缺省

2.strerror:打印errnum出错码对应的出错信息   char *strerror(int errnum)

     errnum:出错errno号     成功返回对应的错误信息      ruturn 1;

3.error:程序出错打印对应出错原因和用户输入字符串并退除 

                 void error(int status, int errnum, const char *format, ...)

status 程序退出的状态:EXIT_FAILURE 1           EXIT_SUCCESS 0

errnum 错误码      format 类似printf打印       返回值:缺省

4.C内置宏:    __FILE__ 表示是哪个文件        

                        __LINE__ 表示第几行

                        __func__ 表示在哪个函数

                        __DATE__

                        __TIME__

5.makefile:     工程管理工具(编译多个.c)

vim 编辑器,gcc 编译器,gdb 调试器(逻辑错误)

目标($^):依赖($@)

规则

make -f 指定makefile

  • 18
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值