I'm passing two std::string's to a function that is creating an alias and echoing it to bashrc in linux and having some problems.
Anyhow, since system() is expecting a char this won't work and I can't seem to figure it out, thanks in advance! (Here is a code snippet that hopefully illustrates what I'm trying to say)
#include <iostream>
int create_alias(std::string&, std::string&);
int main(void)
{
return 0;
}
int create_alias(std::string &alias, std::string &name)
{
#ifndef __linux__
std::cout << "Program not supported, aborting!";
return 1;
#endif
if ( system("echo alias " + name + "='" + alias + "' >> .bashrc") != 0 )
return 1;
return 0;
}