Question

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?

Was it helpful?

Solution

may be this is what you want ?

 cout<< setw(10+token.size()) << token ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top