tags:

views:

44

answers:

4

I tried getline(cin, .... ), but this cannot take input more than one line. The end of input is determined by something like #.

A: 

Can't you just concatenate the strings for each line?

Oli Charlesworth
+3  A: 

You can use getline with a different character than '\n' as the delimeter.

// will collect input until the user enters a #
getline(cin,mystring,'#');
PigBen
A: 

I'd go for conio.h (or whatever else your platform has if it doesn't have conio) and just write an input method myself. That way you can make it much prettier and foolproof.

Vilx-
+1  A: 

Try something like:

#include <iostream>

...

std::string input;
while(1)
{
    input = "";
    std::cin >> input;
    if(input[input.size() - 1] == '#')
        break;
}

Use C++ stuff, not C stuff.

muntoo