streams

Started by
3 comments, last by Zaris 18 years, 8 months ago
How do you handle whitespace in C++? I'm trying to write a function that will accept up to 4 strings as input. Thanks.
Advertisement
Are you trying to read from a file or from an interactive console? What kind of strings are you trying to read? Arbitrary strings written by a machine, strings that represent numbers, names, phone numbers?
streams read through console input.
#include <iostream>#include <sstream>#include <string>int main() {  std::cout << "Give me some strings: ";    std::string temp;  std::getline(std::cin, temp);  std::stringstream sstream(temp);    std::cout << "Your strings were:\n";    while(sstream >> temp)   std::cout << "\t\"" << temp << "\"\n"; }
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Thanks. This bit of code really help me.

This topic is closed to new replies.

Advertisement