0

Hey, what I am trying to do is change the way I assign a title on a dos command prompt, so basically change the title input from:

system("TITLE welcome to my page");

to:

title("Welcome to my page");

I have tried to code it however there are errors:

void title(const char *myTitle &mode)
{
    system("TITLE myTitle");            
}

Any ideas? Thank you

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Phil++
0

You can't use a variable in a string like that, you have to manually add it to the string.

void title(const char *myTitle) // &mode?
{
   std::string command = "title ";
   command += myTitle;
   system( command.c_str() );
}

Also, what is the "&mode" there for?

0

Hey, thank you for all your replies, I got it working :)
Now, I'm creating one for a color command that enables the user to enter something like:

color("blue", "write") // blue background and white text

Like this:

void color(const char *background, char const *text)
{
std::string color = "color";
color += background;
color += textl
system ( color.c_str() );

However, it will only work if the user enters like 1F, so would I create an if statement something like:

if (background == 'Blue') 
    background == '1';

Kind of thing or what else could I use? Thanks :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.