help

Jul 6, 2015 at 8:47am
heloo My code must print only doubles words
Exemple
marius.txt
B
A
C
marius1.txt
A
marius2.txt
is empty

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
  #include <fstream>    
#include <iostream>
#include <string>
using namespace std;


int main()
{
ifstream in("marius.txt"); //deschide fisierele
ifstream in2("marius1.txt");
ofstream end("marius2.txt");
while ((!in.eof()) && (!in2.eof())) 
{                                   //continuare pana la sfarsit
string line, line2;
getline(in, line); //obține linii  
getline(in2, line2);
if (line == line2)
       { //sunt siruri de caractere egal ? adică pe aceeași linie și același lucru ? 
end << line << " Exista egalitate \n";//daca sunt egale tipareste 	
		}

	}

	
in.close();
in2.close();   

end.close();

system("pause");
 return 0;   

	 }
Last edited on Jul 6, 2015 at 8:47am
Jul 6, 2015 at 8:50am
What seems to be the problem? Code behaves as expected.

What do you want outout to contain in the first place?
Jul 6, 2015 at 8:54am
In outstream(marius2.txt)
is empty
must be
a Duble A
Jul 6, 2015 at 9:05am
must appear in marius2.txt only duble word
exemple A must appear
Jul 6, 2015 at 9:23am
You need to rework your program completely. Current one checks lines pairwise
marius.txt	marius1.txt
B	?	A
A	?	-
C	?	- 
No matches
Jul 6, 2015 at 9:30am
mach in A

line by line

A mast be writing in marius2.txt
Jul 6, 2015 at 9:36am
MiiNiPaa wrote:
You need to rework your program completely
Read all content of one file, store it in container and then read second file and compare line to each line stored.
Topic archived. No new replies allowed.