anagram problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BjoernJackschina

    anagram problem

    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(zeil e1,255,'\t')){
    strcpy(tmp1,zei le1);
    in.getline(zeil e1,255,'\n');
    strcpy(tmp3,zei le3);
    double merke=in.tellg( );
    in.seekg(0);
    while ( in.getline(zeil e,255,'\t')){
    strcpy(tmp,zeil e);
    //read letter order
    in.getline(zeil e2,255,'\n');
    strcpy(tmp2,zei le);
    if ((tmp==tmp1)&&( strcmp(tmp2,tmp 5)!=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
  • Leor Zolman

    #2
    Re: anagram problem

    On 12 May 2004 07:38:24 -0700, jacksch_1@hotma il.com (BjoernJackschi na)
    wrote:
    [color=blue]
    >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(zeil e1,255,'\t')){
    > strcpy(tmp1,zei le1);
    > in.getline(zeil e1,255,'\n');
    > strcpy(tmp3,zei le3);
    > double merke=in.tellg( );
    > in.seekg(0);
    > while ( in.getline(zeil e,255,'\t')){
    > strcpy(tmp,zeil e);
    > //read letter order
    > in.getline(zeil e2,255,'\n');
    > strcpy(tmp2,zei le);
    > if ((tmp==tmp1)&&( strcmp(tmp2,tmp 5)!=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[/color]

    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:
    An STL Error Decryptor for C++ by Leor Zolman of BD Software - available to download here

    Comment

    Working...