How to make the message stay centered and blink on the screen in C ++?

2

How to make this message flash on the screen, stay centered and how to change the message color?

    #include <iostream>
    #include <cstdlib>
    #include <windows.h>

    using namespace std;
    string mensagem;
    int main(int argc, char *argv[]) {


    cout << "Digite um palavara: " ;
    cin >> mensagem;

        cout << "***************************" "\n";
        cout << "***************************" "\n";
        cout << "***                     ***" "\n";
        cout << "***                     ***" "\n";
        cout<< "***""\t"<<mensagem<<"\t***""\n";
        cout << "***                     ***" "\n";
        cout << "***                     ***" "\n";
        cout << "***************************" "\n";
        cout << "***************************" "\n";


    system("PAUSE");
    return EXIT_SUCCESS;
}
    
asked by anonymous 12.02.2015 / 16:59

1 answer

2

To centralize is easy. I'm seeing how to blink, which I've seen is not that simple:

#include <iostream>
#include <string>
using namespace std;

string Center(string str) {
   int espacos = (int)((21 - str.length())/2);
   return string(espacos, ' ') + str + string(espacos + (str.length() > espacos * 2 ? 1 : 0), ' ');
}

int main() {
    string mensagem;
    cout << "Digite um palavara: ";
    cin >> mensagem;

    cout << "***************************" "\n";
    cout << "***************************" "\n";
    cout << "***                     ***" "\n";
    cout << "***                     ***" "\n";
    cout<< "***" << Center(mensagem) << "***""\n";
    cout << "***                     ***" "\n";
    cout << "***                     ***" "\n";
    cout << "***************************" "\n";
    cout << "***************************" "\n";

    return 0;
}

See running on ideone . The color does not work on it.

    

12.02.2015 / 17:47