B
BjoernJackschina
Hello,
many thanks for the solution of my last problem but I think I will use
my own simple solution. I want to find anagrams. The file "d.txt"
looks like this:
opts stop
fnu fun
opts post
opts tops
emos some
So I compare every word order but in my programm I can only read the
first dataset and then it is stoped. What is the mistake?
#include "stdafx.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{ ifstream in("d.txt");
char zeile[256];char zeile1[256];char zeile2[256];
string tmp = "";string tmp1= "";string tmp2= "";
in.seekg(0);
while ( in.getline(zeile1,255,'\t'))
{ tmp1 = zeile1;
in.getline(zeile1,255,'\n');
double merke=in.tellg();
in.seekg(0);
while ( in.getline(zeile,255,'\t'))
{ tmp = zeile;
in.getline(zeile2,255,'\n');
tmp2=zeile2;
cout << tmp << " " << tmp2 << endl;
if (tmp==tmp1&&tmp2!=tmp1)
{
cout << string(zeile2) << endl;
}
}
in.seekg(merke);
}
return 0;
}
Many thanks
Bjoern
many thanks for the solution of my last problem but I think I will use
my own simple solution. I want to find anagrams. The file "d.txt"
looks like this:
opts stop
fnu fun
opts post
opts tops
emos some
So I compare every word order but in my programm I can only read the
first dataset and then it is stoped. What is the mistake?
#include "stdafx.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{ ifstream in("d.txt");
char zeile[256];char zeile1[256];char zeile2[256];
string tmp = "";string tmp1= "";string tmp2= "";
in.seekg(0);
while ( in.getline(zeile1,255,'\t'))
{ tmp1 = zeile1;
in.getline(zeile1,255,'\n');
double merke=in.tellg();
in.seekg(0);
while ( in.getline(zeile,255,'\t'))
{ tmp = zeile;
in.getline(zeile2,255,'\n');
tmp2=zeile2;
cout << tmp << " " << tmp2 << endl;
if (tmp==tmp1&&tmp2!=tmp1)
{
cout << string(zeile2) << endl;
}
}
in.seekg(merke);
}
return 0;
}
Many thanks
Bjoern