By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

anagram problem

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 12 May 2004 07:38:24 -0700, ja*******@hotmail.com (BjoernJackschina)
wrote:
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
--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.