Hi, I'm new to the forum. Sorry fo my bad English
I've a problem to distinguish symbolic link from file, I created a link ("mylink") to a file, but when I run the following code,
1. On Debian (gcc-4.3), I get that it is a regular file
2. On Windows (Dev-C++), I get this error: "undefined reference to S_ISLNK"
Code:
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
struct stat file;
int status;
main() {
status = stat("/home/mario/Desktop/mylink", &file);
if (S_ISLNK(file.st_mode))
printf("Is a link\n");
else if (S_ISREG(file.st_mode))
printf("Is a file\n");
}
How can I fix the problem?
Thanks!