Getting the user's local username

This is a discussion on Getting the user's local username within the C Programming forums, part of the General Programming Boards category; Hi all,
I'm trying to write a program in a Linux enviroment that parses through some xml files, that reside ...

Getting the user's local username

Hi all,

I'm trying to write a program in a Linux enviroment that parses through some xml files, that reside in the user's home dir. The problem is getting that user's username, so I can put together the path to those files (e.g. /home/username/.hiddendir/file.xml).

I've looked as much as I can, but can't find a way to dynamically, during program execution, get the user's username on the OS. Does anyone know how this could be done?

Actually, no, it didn't. Thought at first that it had worked, since I got no errors from my program. But that just turned out to be a bug in my code. The code you posted, worked though, so I've been able to continue my project. Thank you for that.