How do I create a soft link programmatically in C/C++?

Professor_Chaos picture Professor_Chaos · Sep 30, 2014 · Viewed 17.3k times · Source

How do I create a soft link programmatically in C/C++? link() system call in freebsd will create a hard link.

Answer

Mike Seymour picture Mike Seymour · Sep 30, 2014

The system call you want is symlink(2).

#include <unistd.h>

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

A symbolic link name2 is created to name1