Hello I'm trying to make C program which arguments will be files and it will print the owner of each file. But i'm facing a problem. I use stat() function to save information for the files but when i use st_uid it prints user id. But i want not to print id i want to print the username of the owner. Is there any function i can use to do that. Here is my code:
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include<errno.h>
int main(int argc, char **argv){
struct stat st;
for(int i=1;i<argc;i++){
int t = stat(argv[i],&st);
if(t!=0){
perror("stat:");
return 1;
}
printf("%s %d\n",argv[i],st.st_uid);
}
return 0;
}