Programming challenge

Hello again Cplusplus forum!

Thought I solved my last problem with my programming challenge but now have I encountered new problem with my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string words, word2;

	cout << "Input exactly one word on each row.\nEnd your input with the word done" << endl;
	

	while(words != "Done" && words != "done")
	{
		cin >> words;

		word2 +=words;
		word2 += " ";

	}
	cout << word2 << endl;
}


You see, I don't wanna have the word "Done" in my output string in the end of the program. Dunno really how do solve this problem.
Can someone give me a tip?

Last edited on
where you have

int main()

you have to inclose everything in the
1
2
{
          }

you have the first { but not the second one
Ahh okay I missed that. But the problem is in the:
while(words != 'done' || words != 'Done');

For me it says "Error no operator matches these operands".

So can't I use a string to compare in a do-while loop?
while(words != 'done' || words != 'Done');
Use double quotes with strings, not single quotes. Also, change || to &&.
Thank you! That was a easy fix!
Topic archived. No new replies allowed.