check file .txt ??

hello everyone again hhhh =D

in here there is tow line have same link :

https://www.cjoint.com/doc/20_11/JKjwxsY8IYv_newhj.txt

I try find them by this function but I'm very stupid hhhhhhhhh :'(

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
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	std::ifstream if1("newhj.txt");
	std::ifstream if2("newhj1.txt");

	if (!if1.is_open())
		return (std::cout << "Cannot open files\n"), 1;

     int cnt1= 0, cnt2=0;
	for (std::string f1; std::getline(if1, f1); ++cnt1) {

        for (std::string f2; std::getline(if2, f2); ++cnt2){
		if (f1 == f2 ){

            cout << f1 << endl;
        }

		}


	}
	cout << cnt1 << " instances found\n" ;
	cout << cnt2 << " instances found\n" ;
}


please anyone can help ❤️ ❤️ ❤️

Last edited on

I'm close to doing it hhhh =D

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
41
42
43
44
45
46
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	std::ifstream if1("same.txt");
	std::ifstream if2("same1.txt");

	if (!if1.is_open())
		return (std::cout << "Cannot open files\n"), 1;

     int cnt1= 0, cnt2=0, cnt3=0;

     string f1, f2, f3;
     std::getline(if1, f1);
     std::getline(if1, f2);

     if( f1 == f2){

     cout << f1 << endl;

     }else {

            for(f1; std::getline(if1, f3);){


               if( f1 == f3 ){

                cout << f1 << endl;

                }

       }

     }

//	cout << cnt1 << " instances found\n" ;
//	cout << cnt2 << " instances found\n" ;


}

I don't understand the requirement - never mind the issue you are having. You provide the contents of newhj.txt file but your code also uses newhj1.txt file?

Would you explain in more detail what you are trying to achieve.

@seeplus

No No bro don't care about the names I'm just copy the same file and Rename it by newhj1.txt

There is only one file this is it :

https://www.cjoint.com/doc/20_11/JKjwxsY8IYv_newhj.txt

if you look at my last reply I'm use different names << same.txt >> and << same1.txt>

I'm just try by many method hhh =D
Last edited on

Now I'm very very close to doing it ...


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
41
42
43
44
45
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	std::ifstream if1("same.txt");

	if (!if1.is_open())
		return (std::cout << "Cannot open files\n"), 1;

     int cnt1= 0, cnt2=0, cnt3=0;

     string f1, f2, f3;
     std::getline(if1, f1);
     std::getline(if1, f2);

     if( f1 == f2){

     cout << f1 << endl;

     }else {

            for(f1; std::getline(if1, f3);){

               if( f1 == f3 ){

                cout << f1 << endl;

                }
                f1 = f2 ;

       }

     }

//	cout << cnt1 << " instances found\n" ;
//	cout << cnt2 << " instances found\n" ;


}

Last edited on

wooowooow this for loop should be repeat " 3256220 times " hhhhhhhhhhhhh I think I need super computer =D


is there any other method please ❤️ ❤️ ❤️
If you explain what you're trying to do.......
If you explain what you're trying to do
By
In here there is tow line have same like :
I think he means he wants to find duplicate lines. His English is not so good (and I don't know Arabic).

The file has 1 copied line:
https://github.githubassets.com/images/icons/emoji/unicode/1f3f3.png

It is repeated 2 times.
http://coliru.stacked-crooked.com/a/d1f118fc0e09fc9c
Last edited on
This will display all duplicate lines and create a new file without the duplicates (but not in the same order):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <fstream>
#include <set>
#include <string>

int main()
{
	std::ifstream ifs("newhj.txt");

	if (!ifs.is_open())
		return (std::cout << "File not open\n"), 1;

	std::set<std::string> ss;

	for (std::string line; std::getline(ifs, line); )
		if (ss.insert(line).second == false)
			std::cout << line << '\n';

	std::ofstream ofs("newhj1.txt");

	for (const auto& l : ss)
		ofs << l << '\n';
}


@mbozzi
@seeplus

wooooooooooooowooooooooooowwwwooooooooooooooo Thank you So much brothers this is what I want this link is duplicate :

https://github.githubassets.com/images/icons/emoji/unicode/1f3f3.png

Thanks Thanks Thanks Thanks ❤️ ❤️ ❤️

I'm so sorry my English is not good :'(

but really really I hope be someday professional programmer like you :'(

I was started think it's impossible find it hhhhhhhh =D

Last edited on
Topic archived. No new replies allowed.