Use getline with delimiter?

Hello I need your help, obviously.

I'm making a program that converts mores code to text but I have a problem when
I have to continue reading after the first delimiter.

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
				string input;
				cout << "Enter your message: ";

				
				int isize;
					do
					{
						cin.clear();
						getline(cin, input, '/');
						isize = input.length();
			MorsCode.SearchForMoresOrderToBST(SymbolToNumber(input));

					} while (input[isize-1] != '\n');


Where MoresCode is a class that contains a symbol which will output when is found.

My problem really just is separating the input which will look something like:

1
2
Enter a message: .-/-.../
Translation: AB


Now if I do this separately like:

1
2
      getline(cin, input, '/'); MorsCode.SearchForMoresOrderToBST(SymbolToNumber(input));
      getline(cin, input, '/');							MorsCode.SearchForMoresOrderToBST(SymbolToNumber(input));


It works, for only two delimiters that is, how about for until the user enters the enter '\n' key?

Would really appreciate some suggestions!
Read whole line and put it in the string stream and then parse it in a loop:
1
2
3
4
5
6
std::string input;
std::getline(std::cin, input);
std::istringstream line(input);
while(std::getline(line, input, '/')) {
//...
}
Topic archived. No new replies allowed.