anagram problem

B

BjoernJackschina

Hello,
many thanks for all good tipps up to now.
It's read a textfile in this structure:
opst post
opst stop
aagin again
enw new
and so on.

int main(){
ifstream in("test.txt");
char zeile[256];char zeile1[256];char zeile2[256];
char tmp[256] = "";char tmp1[256]= "";char tmp2[256]= "";
char tmp3[256]= "";
in.seekg(0);
while ( in.getline(zeile1,255,'\t')){
strcpy(tmp1,zeile1);
in.getline(zeile1,255,'\n');
strcpy(tmp3,zeile3);
double merke=in.tellg();
in.seekg(0);
while ( in.getline(zeile,255,'\t')){
strcpy(tmp,zeile);
//read letter order
in.getline(zeile2,255,'\n');
strcpy(tmp2,zeile);
if ((tmp==tmp1)&&(strcmp(tmp2,tmp5)!=0)){
cout << zeile2 << endl;
}
}
in.clear();
in.seekg(merke);
}
return 0;
}
How can I prevent that double existing words will be shown.
Many thanks for reply
 
L

Leor Zolman

Hello,
many thanks for all good tipps up to now.
It's read a textfile in this structure:
opst post
opst stop
aagin again
enw new
and so on.

int main(){
ifstream in("test.txt");
char zeile[256];char zeile1[256];char zeile2[256];
char tmp[256] = "";char tmp1[256]= "";char tmp2[256]= "";
char tmp3[256]= "";
in.seekg(0);
while ( in.getline(zeile1,255,'\t')){
strcpy(tmp1,zeile1);
in.getline(zeile1,255,'\n');
strcpy(tmp3,zeile3);
double merke=in.tellg();
in.seekg(0);
while ( in.getline(zeile,255,'\t')){
strcpy(tmp,zeile);
//read letter order
in.getline(zeile2,255,'\n');
strcpy(tmp2,zeile);
if ((tmp==tmp1)&&(strcmp(tmp2,tmp5)!=0)){
cout << zeile2 << endl;
}
}
in.clear();
in.seekg(merke);
}
return 0;
}
How can I prevent that double existing words will be shown.
Many thanks for reply

If you'd like feedback on /improving/ an existing program, please show a
complete, correct, compilable program (including #includes) to begin with.
What you've shown above has numerous errors, whether they be typos or
logical. You use several undefined identifiers, and the line
if ((tmp == tmp1) ...
is probably not doing what you think it is doing. There's just too much to
try and fix in order to see it run and get to the point of being able to
think about your question.
-leor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top