如何在C/C++中以编程方式创建软链接?

Pro*_*aos 10 c c++ symlink freebsd

如何在C/C++中以编程方式创建软链接?freebsd中的link()系统调用将创建一个硬链接.

Mik*_*our 18

你想要的系统调用是symlink(2).

#include <unistd.h>

int symlink(const char  *name1, const char *name2);
Run Code Online (Sandbox Code Playgroud)

name2创建符号链接name1


SSC*_*SSC 5

你可以打电话 symlink()

int  symlink(const char *name1, const char *name2);

A symbolic  link name2 is created to name1 (name2 is the name of the file
created, name1 is the string used in creating the symbolic  link).  Either
name may be an arbitrary path name; the files need  not be on the same
file system.
Run Code Online (Sandbox Code Playgroud)