In C programming how do you get the current user and the current working directory. I'm trying to print something like this:
asmith@mycomputer:~/Desktop/testProgram:$
(user) (computerName) (current directory)
I have the following code, but the username is showing as NULL. Any ideas what I'm doing wrong?
void prompt()
{
printf("%s@shell:~%s$", getenv("LOGNAME"), getcwd(currentDirectory, 1024));
}