unique words from file!!

its been 3 days i just cant identify whats wrong with the program the program should compare words by words instead it only comparing a character to charcter its is showing like if i have words like (aaa bbb cc dd ) the result its printing is a b and same is the sentence file if i put paragraphs to compare its only comparing few character please help me

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
     
	
	ifstream myfile("uniq.txt");
	int count = 0;
	string temp;
	string a;

	int i,j;
	
while(getline(myfile, temp))
		
	{
		
		
		
		for(i=0;i<sizeof(temp);i++)
		
		{
			for(j=0;j<i;j++)
			{
				if (temp[i] == temp[j])
				break;
        	
        	}
        	
        	
		if (i == j)
        cout<< temp[i]<<",";
				
		}
		
myfile.close();

}
Last edited on
Please edit your post for readability.
https://www.cplusplus.com/articles/jEywvCM9/
Please check now!
At least one mistake is on line 22: Replace sizeof(temp) with temp.size()
Topic archived. No new replies allowed.