Domanda

Basically what I'm trying to do is to distribute spaces equally between words of a given string. This is what I did:

istringstream s("En el infinito y mas alla"); 
string token;
while( s >> token )
{
    cout << token << setw(10);
}

However, this is not working as expected. Anybody know why?

È stato utile?

Soluzione

may be this is what you want ?

 cout<< setw(10+token.size()) << token ;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top