Getting rid of white space in string loops

Hi, i'm fairly new to programming and have to create a program where the user inputs a word, it is then outputted in the 11th column of a 20 column grid of random '1' '0' '.' and ' '. I got it to work with string inputs of one word, but when you enter multiple words, it just does the first word. Any ideas how to fix this?

#include <iostream>
#include <string>

using namespace std;


int main()


{


string a = "10. ";
string b;
int t = 0;


cin >> b;


srand(time(NULL));
char x;


for (int z = 0; z < b.length(); z++)
{
for (int i = 0; i < 19; i++)

{
x = a[rand() % a.length()];
cout << x;

if (i == 9)

{
cout << b.at(t);
}
}
t++;
cout << endl;
}

cout << endl;

}

The operator>> does formatted input and treats whitespace as separator.
See http://www.cplusplus.com/reference/string/string/operator%3E%3E/

std::getline does unformatted input.
See http://www.cplusplus.com/reference/string/string/getline/
Thank you!
Topic archived. No new replies allowed.