p4-2.c

来自「SUN Solaris8平台下进程间通信」· C语言 代码 · 共 24 行

C
24
字号
#include <stdio.h>#include <stdlib.h>#include <sys/stat.h>#include "err_exit.h"int main(void){    int         link_value;    const char  *path1 = "testfile1";    const char  *path2 = "testfile2";    struct stat orig_buf, new_buf;    printf("create testfile\n");    creat(path1, S_IRWXU|S_IRWXG|S_IRWXO);    printf("get testfile1 status\n");    stat(path1, &orig_buf);    printf("orig_buf.st_nlink=%d\n", orig_buf.st_nlink );    printf("create link from %s to %s\n",path1,path2);    if (link(path1, path2))        err_exit("link() call failed");    printf("link() call successful\n");    stat (path1, &new_buf);    printf("new_buf.st_nlink=%d\n", new_buf.st_nlink );    return(EXIT_SUCCESS);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?