Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
File uid to Username in C++ using lstat

Posted by hjortur (hjortur), 19 November 2007
Hi. I am writin a program in C++ that takes file information from files using lstat...but when I come to the part of writing out the username I only get uid using lstat. Is there an easy way to extract this info from the system ...perhaps using the passwd file along with uid?

Posted by george_Ball (george), 20 November 2007
You have to use a lib function called getpwuid, which returns you a pointer to a structure that contains all the info form the password file, amongst which is the user's name.

That's what tools like ls do - remember once you have logged in to a Unix system you cease to have a name, only a number (your uid)...

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho