Change prompt values from within a C++ program
I am trying to write a "minishell" program in C++ to demonstrate execv, fork(), wait(), getpid(), etc. I need to have the C++ program display a prompt to the user of the format "username@hostname:current directory:$" I have tried the following without success:
int main()
{
putenv("PS1 = \u@\h\w$");
char *prompt = getenv("PS1");
cout << prompt;
}
The putenv as I have it is giving me compilation errors and the cout << prompt is giving me the values of PS1.
I would like cout << prompt; to give me the following
username@hostnamecurrentdirectory$
any help would be greatly appreciated.
|