Problems with setw (x)

0

For some reason setw (number) does not leave spaces. I have the corresponding library and I think the nomenclature is correct.

#include<iostream>
#include<fstream>
#include<string>
#include<stdlib.h>
#include<time.h>
#include <iomanip>

using namespace std;

int const TAM_CODIGO=4;

typedef enum{ROJO,AZUL,VERDE,AMARILLO,MARRON,BLANCO} tColor;
typedef tColor tCodigo[TAM_CODIGO];

void menu();
void textoMenu();
void codigoHumano(tCodigo hipotesis);
void codigoAleatorio(tCodigo codigo, bool admiteRepetidos);
char colorMaquina(tColor a);
void compararCodigos(const tCodigo codigo, const tCodigo hipotesis, int& colocados, int& descolocados);


int main()
{
    cout << setw(6) << "[Este programa no usa tildes por motivos tecnicos]" << endl << endl;
    cout << setw(6) << "Mastermind" << endl << setw(6) << "==========" << endl << endl;
    cout << "Descubre el codigo secreto! En cada partida, pensare un codigo de colores que tendras que adivinar. ";
    cout << "En cada intento que hagas te dare pistas, diciendote cuantos colores de los que has dicho estan bien colocados, y cuantos no.";
    cout << endl<< endl << "Averigua el codigo secreto en el menor numero posible de intentos!" << endl <<endl;
    menu();
    return 0;
}
    
asked by Vendetta 13.01.2018 в 13:16
source

1 answer

2

What happens is that the number of letters that the text has is greater than the alignment, if you place for example 55 you will notice it moves. To put it simply, the setw moves as many spaces to the right as you indicate and then writes the text to the left, so if the text is greater than the amount of the setw, it will move when filling the spaces of the setw.

    
answered by 13.01.2018 / 13:35
source