Reputation: 545
i'm trying to make a function that outputs n amount of colored spaces or " ". I specifically need it to be a quote string thing (not s) because I'm sending as an argument to the system() function.
is there a way that I can use a char variable inside a string.
I need it to function like this(I know it won't work):
system("echo -e \"\e[45m _myCharHere_ \"");
this way I can make the spaces (" ") any size I choose by multiplying the char by what ever integer I choose.
This is probably a stupid question, but I don't know all the technical programming terms for these operations etc; so I can't google it.
Thanks
Upvotes: 0
Views: 142
Reputation: 217185
You may use something like:
// Assuming mychar doesn't need escape sequence.
std::string command = std::string("echo -e \"\e[45m ") + myChar + " \"";
system(command.c_str());
Or as mentioned in comment, write directly (and here myChar can be special char):
std::cout << "\033[45m " << myChar;
Upvotes: 1