[LC++]unistd.h & getlogin()

Keith Schincke kschin at unf.edu
Fri Jul 27 04:36:02 UTC 2001

On Thu, 26 Jul 2001, ljp wrote:

> getlogin() seems to be broken, and always returns NULL. Is there any other functions to get the users login?
> ljp

That is odd but below works for me. You could also use getenv() but then
you would have to trust the user enviroment.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

void main(void)
	char* user;

	//user = getlogin();
	user = cuserid(NULL);

		fprintf(stdout,"Login: %s\n",user);
		fprintf(stdout,"Who dat?\n",user);


Keith Schincke           My dawg is always with me.
Jacksonville, Fl               00 Spool - Wild at Heart
http://www.unf.edu/~kschin                           Email: kschin at unf.edu
++The opinions in my email are mine only and are not those of my employer++

Come on, we're not out of this yet!

More information about the tuxCPProgramming mailing list