[問題] getpwnam()不同電腦上的執行結果不一樣
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) C
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) pwd.h
問題(Question):
我在A 電腦 利用 getpwnam 寫一個簡單的驗證器
但我編譯完成後拿到B電腦 getpwnam 卻無法抓到資料
餵入的資料(Input): getpwnam("root")
預期的正確結果(Expected Output): UID = 500
GID = 500
錯誤結果(Wrong Output): ERROR
程式碼(Code):(請善用置底文網頁, 記得排版)
struct passwd *pwd = getpwnam("root");
if (NULL == pwd)
{
printf ("ERROR\n");
return;
}
printf("UID = %s",pwd->pw_uid);
printf("GID = %s",pwd->pw_gid);
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.35.110.23
※ 編輯: kuangs 來自: 114.35.110.23 (08/07 17:49)
→
08/07 20:11, , 1F
08/07 20:11, 1F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章