I have the following code in C. I run it at FreeBSD. I compile it as cc -o bbb bb.c
. Then run and get the output
$ ./bbb
-1
stat: No such file or directory
This is the Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
int main() {
struct stat *st;
int stat_code =0;
stat_code = stat("/", st);
printf("%d\n", stat_code);
perror("stat");
return 0;
}