在 C 中,我如何获得符号链接的路径(我的意思是符号链接的路径而不是目标)?

In C how do i get the path of a symlink (I mean the path to the symlink not to the target)?

在 C 中,如何获取符号链接的路径(我指的是指向符号链接的路径,而不是指向目标的路径)?

因为当我使用 realpath() 并将符号链接的名称作为参数时,我得到了目标的路径。

有没有办法获取符号链接本身而不是目标的路径?

在 Linux(以及其他 POSIX 系统)上,您可以使用 readlink(2)