Hirdetés

Új hozzászólás Aktív témák

  • lvb

    aktív tag

    válasz pite_r1 #523 üzenetére

    nagyjából. Ha vannak bene hibák, javítsd ki. :)

    #include <list>
    #include <string>

    class CMyString
    {
    public:
    CMyString( char * aData ) { data = aData; }
    std::string data;
    bool operator < (const CMyString& txt1)
    {
    return( data < txt1.data);
    }

    };

    ...

    FILE * fp;
    char strv[255]; //max 255 char / line
    const char src[] = ''áÁéÉíÍóÓűŰöÖ'';
    const char newVal[] = ''aAeEiIoOuUoO'';
    int srcLen = sizeof( src );
    std::list<CMyString> lText;

    if( (fp = fopen( ''aaa.txt'', ''r+t'' )) == NULL ) return; //Error
    while( !feof( fp ) )
    {
    fgets( strv, sizeof(strv) ,fp );
    strv[254] = 0; //security...
    for( unsigned int i = 0; i < strlen( strv ); i++ )
    {
    for( int j = 0; j < srcLen; j++ )
    {
    if( strv == src[j] ) strv = newVal[j];
    }
    }
    lText.push_back( CMyString(strv) );
    }
    fclose( fp );

    if( (fp = fopen( ''aaa1.txt'', ''a+t'' )) == NULL ) return; //Error

    lText.sort();
    std::list<CMyString>::iterator iT = lText.begin();
    while( iT != lText.end() )
    {
    fprintf( fp, ''%s'', iT->data.c_str() );
    iT++;
    }
    fclose( fp );

    soronként meg nincs komment, az nem járja :)...

Új hozzászólás Aktív témák