Reputation: 534
I need to be able to change the prompt on running an executable of a c file to get a custom prompt
E.g:
$ abc
abc>
Here the user can give the commands acceptable to the program. I saw this happen for programs like MySQL and was wondering if it is possible to do this.
Upvotes: 1
Views: 82
Reputation: 5806
You can use gnu readline for custom prompt
#include <readline/readline.h>
#include <readline/history.h>
while (1)
{
command = readline ("$abc");
command = readline ("abc>");
//validate your command name
system(command);
add_history (command); ///add command in history
}
Upvotes: 2
Reputation: 24812
you can include the readline library in your program to make it have a modern command line interface.
Or you can simply build a loop get each line from input and get the tokens from that line of input to execute commands, and there printout your abc>
prompt.
Upvotes: 1