This the the function prototype for stat() from man 2 stat
int stat(const char *path, struct stat *buf);
Your code will get segmentation fault, because address of structure variable need to pass in stat() function.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
struct stat st;
int stat_code =0;
stat_code = stat("test.txt", &st);
printf("%d\n", stat_code);
perror("stat");
return 0;
}
above will help you. For reference
man 2 stat