Cards against Humanity code.

I'm currently taking a CS100 course in my freshman year and I've been given a project which is to create the card game 'cards against humanity'. I have a few questions reagarding this. For those of you who arent familiar with the game, it basically is a game with 4 players and each player is given 10 white cards randomly from the deck. One of the player is the card czar and has a black card with a question on it and the other 3 players answer the black card with one of their white cards. The card czar chooses which answer is funniest and gives that player a point.

the first is I found .txt files for all the black and white cards online and I imported them into my program and stored them in a vector. The only problem is each word i output line by line. How can i make it so that the entire question is printed on a single line. My code for storing the file in a vector is:

void BlackCards(vector<string> BlackCards)
{
string s;
ifstream readfile;
readfile.open("BlackCards.txt");

if(readfile.is_open())
{
while(!readfile.eof())
{
readfile >> s;
BlackCards.push_back(s);
cout<<s<<endl;

}
}
else{cout<<"unable to open file"<<endl;}
readfile.close();
}

And the output is shown as: (this just an example not the entire output)
q
Why
can't
I
sleep
at
night?
q
What's
that
smell?


My second question is how can i pick 10 random white cards from the vector i created and assign them to 3 different players. I know there's rand fucntion, but how would i go about that.


My third and final question is, is there anyway I can open multiple terminal at once when i run my code? One terminal for each player.


thanks, any help would be appreciated.
 
readfile >> s;


s is a string, so it will only read up until it hits a white space

you want to use
 
getline(readfile,s)
Topic archived. No new replies allowed.