[問題] getpwnam()不同電腦上的執行結果不一樣

看板C_and_CPP (C/C++)作者 (kuangs)時間12年前 (2013/08/07 17:49), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
開發平台(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
去看errno 如果不知道errno是什麼的話去翻APUE書
08/07 20:11, 1F
文章代碼(AID): #1I0XWH61 (C_and_CPP)
文章代碼(AID): #1I0XWH61 (C_and_CPP)