Ok im new to C++ so please help, so I have this line of code.

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
cout << "Congratulations your power level is now" << PowerLevel << endl;

insted of typing this all the time can i just add it to another cpp file and just reference it or something like that ?

Sorry if i titled it wrong buy as i said im new.

Sure. You'd wrap the lines in a function and simply call the function when you need those lines to be executed:

void show_powerlevel()
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
    cout << "Congratulations your power level is now" << PowerLevel << endl;
}

...

// Use it like this:
show_powerlevel();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.