showing words separatly in a string

hi

i am trying to display words in string separatly. What do i want is to display all the words in a string which is entered by user but do not dislay those words twice which are repeated in that string.

here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>
#include <cctype>

int main()
{
	string input = "";
	getline(cin, input, '#');
	
	for(int i = 0; i < input.length(); i++) {
			if(input[i] == ' ') {
				cout << endl;
			} else {
				if(!ispunct(input[i])) {
					char lowerString = tolower(input[i]);
					cout << lowerString;
				}
			}
		
	}

	cout << endl;
	return 0;
}


when i enter this string
1
2
3
4
5
enter string
this is string
what do you think
this is char
# 


here in this string the word "string" and "this" and "is" are repeated. what i want to to display these words like this
1
2
3
4
5
6
7
8
9
enter
string
this
is
what
do
you
think
char


please help
Last edited on
Topic archived. No new replies allowed.