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
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

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 www.opentalk.org.uk 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., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho