stat구조체에서요..

geneven의 이미지

st_uid라는거는 정수값인가요?

텍스트로 된 아이디를 얻으려면 어떻게 해야하나요?

rokmn3309의 이미지

st_uid는 unsigned int __u_int 값입니다.
다음건 제가 특정파일의 소유자랑 사용자 홈디렉토리 읽어오는걸
함 만들어봤습니다.

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>

int main(){
        struct stat stbuf;
        struct passwd *fpwd;

        if(stat("./aaa.c",&stbuf)==0){
                printf("%d  \n",stbuf.st_uid);
                fpwd=getpwuid(stbuf.st_uid);
                if(fpwd!=NULL){
                        printf("%s  %s\n",fpwd->pw_name,fpwd->pw_dir);
                }
        }
        return 0;
}