Ofstream - Kleines Prob!?



  • hae wie(so) vor der if abfrage 😕 😕



  • Wenn du es nach den if-Blöcken schreibst, landet die Zeilennummer an der falschen Stelle in der Ausgabedatei 😉

    alternativ kannst du auch die Ausgabe in jedem if-Block ergänzen:

    if(bed1)
      [b]fout<<nummer<<" - "[/b]<<ersatz1;
    else if(bed2)
      [b]fout<<nummer<<" - "[/b]<<ersatz2;
    else if...
      ...
    else
      [b]fout<<nummer<<" - "[/b]<<zeile;
    


  • so hab ich das doch :)!

    aber.. ich lesee DATEI1 ein ins programm

    'NUMMER' > 'BROWSERTYP BEZEICHNUNG'

    -------------------------

    dann werden die if fragen durchgeklappert ... normaler weiße müsse es so ausehen

    == 'NUMMER' > 'KURZE BROWSERBESCHREIBUNG' ==

    --- sieht aber so aus ---

    'BROWSERTYP' 'BEZEICHNUNG'

    😕 😕 😕 😕 😕

    EDIT;// Ich zeig nochma den Aktuellen Code:

    ( Die erste IF frage: Da hab ich was getestet klappt aber auch nicht.. und die 2te if abfrage ist so wie ichs von anfang an hatte)

    #include <cstdlib>
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    
    {
    
    char fileName[80];
    
    char buffer[255];
    
    char newFileName[80];
    
    cout << "Dateiname: "; // Eingabe Welche Datei gelesen werden soll
    
    cin >> fileName; // Variable für den Dateiname
    
    cout << "Neuer Dateiname: ";
    
    cin >> newFileName;
    
    ifstream fin(fileName); ofstream fout(newFileName);
    
    string zeile;
    
    while(getline(fin, zeile)) //zeilenweise einlesen
    
    {
    
    string::size_type sp_pos = zeile.find(' ');
    
    string nummer = zeile.substr(0,sp_pos); //erster Abschnitt
    
    zeile.erase(0,sp_pos++);              //Restzeile
    
    if(zeile.find("(compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",0)!=string::npos)
    
    {
    
           string FireFox17("Fire Fox 1.0.7");
           zeile.replace(sp_pos,FireFox17.length(),FireFox17);                     
           fout << nummer << ' ' << zeile << endl;               
    
    }
    
    else if(zeile.find("Mozilla/4.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5)",0)!=string::npos)
    
    {
           zeile = "hallo3";
           fout << nummer << ' ' << zeile << endl;
    
    }
    
    else fout << zeile << endl;
    
    }
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    


  • Kann keiner helfen? Ich verzweifel echt 😞 !!



  • Ich frag nochma :/!

    Kann mir hier keiner sagen wie ich eine Textzeile in einer Text datei lesen und ersetzen kann

    z.B

    Der hund und die Katze!

    in

    Hund und Katze!



  • Da eine Textdatei variable Satzlängen (zu Deutsch "Textzeilen") enthält ist der einzig praktikable Weg das Schreiben einer neuen Textdatei mit den geänderten Zeilen...



  • na soweit sind wir doch schon längst

    les dir ma meinen code duch und schau was ich falsch mache! Eig. sollte es so gehen aber tuts irgendwie net



  • dogeye schrieb:

    aber.. ich lesee DATEI1 ein ins programm

    'NUMMER' > 'BROWSERTYP BEZEICHNUNG'

    dann werden die if fragen durchgeklappert ... normaler weiße müsse es so ausehen

    Direkt nach dem Auslesen dürfte beides zusammen in 'zeile' stehen - nach den Vorverarbeitungen (also am Beginn der if()-Kette) steht in 'nummer' die aktuelle Nummer und in 'zeile' der Teil 'BROWSERTYP BEZEICHNUNG'

    == 'NUMMER' > 'KURZE BROWSERBESCHREIBUNG' ==

    Das erreicht du mit dem "fout<<nummer<<' '<<...; innerhalb jedes if()-Abschnittes.

    'BROWSERTYP' 'BEZEICHNUNG'

    Erstens fehlt in der letzten Ausgabeanweisung (das unterste else) der Teil, der für die Nummern-Ausgabe zuständig ist. Und zweitens sehen deine Abfragen etwas zu spezifisch aus - wenn nur ein Zeichen nicht ganz stimmt, liefert die Bedingung false und du endest bei der Standard-Behandlung.

    PS: Übrigens sind großes 'H' und kleines 'h' zwei verschiedene Zeichen.



  • Ey sorry ich hab nen brett vorm kopf ich check ganix mehr wenn ich mir deine erleuterung so durch lese, lese ich das so als ob ich das schon habe im code? Oh man :/!



  • Ja, das habe ich aus deinem Code abgeleitet 😉

    Dein Problem teilt sich in zwei Teile auf:
    a) dem letzten else fehlt die Ausgabe der Zeilennummer:

    if()
      ...
    else
      fout<<nummer<<' '<<zeile;//Default-Verhalten - wenn kein if() zugeschlagen hat
    

    b) deine Vergleichsstrings sind möglicherweise zu spezifisch - da reicht schon ein Buchstabendreher oder ein vergessene Leerzeichen und find() findet den String nicht mehr wieder. (vielleicht wäre es angebracht, nach kürzeren Teilstücken zu suchen, notfalls mit && kombiniert)

    if(zeile.find("Hund")!=string::npos && zeile.find("Katze")!=string::npos)
      //die Worte "Hund" UND "Katze" kommen vor
      fout<<nummer<<' '<<"wie Hund und Katze\n";
    


  • hm jo das hab ich schon alles probiert :/!

    #include <cstdlib>
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    
    {
    
    char fileName[80];
    
    char buffer[255];
    
    char newFileName[80];
    
    cout << "Dateiname: "; // Eingabe Welche Datei gelesen werden soll
    
    cin >> fileName; // Variable für den Dateiname
    
    cout << "Neuer Dateiname: ";
    
    cin >> newFileName;
    
    ifstream fin(fileName); ofstream fout(newFileName);
    
    string zeile;
    
    while(getline(fin,zeile)) //zeilenweise einlesen
    
    {
    
    string::size_type sp_pos = zeile.find(' ');
    
    string nummer = zeile.substr(1,sp_pos); //erster Abschnitt
    
    zeile.erase(0,sp_pos+1);
    
    if(sp_pos == ("1.0.3705)",0)!=string::npos)
    
    {
                 zeile = "FireFox 1.7";
                 fout << nummer << ' ' << zeile << endl;
    
    }
    
    else if(sp_pos == ("rv:1.7.5)",0)!=string::npos)
    
    {
                zeile = "hallo3";
                fout << nummer << ' ' << zeile << endl;
    
    }
    
    else        fout << nummer << ' ' << zeile << endl;
    
    }
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    

    das ist ein teil der Text datei: Wär kewl wenn du mal mein Proggy testen würdest evlt. siehst dann das was ich meine 😞

    47	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    44	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; AtHome033; SV1)"
    558	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    73	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)"
    156	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
    54	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; DigExt)"
    45	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    53	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    163	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    120	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
    358	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    48	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    122	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ESB{1AA6D75B-C13D-4056-C786-F394AF0C16C9}; ESB{17004370-938E-48BE-B146-8CAB5CC28F47}; SV1; .NET CLR 1.0.3705)"
    51	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    72	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    46	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    123	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; ZON)"
    90	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    94	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    76	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    430	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    93	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    236	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    50	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    71	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    49	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    117	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    100	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    97	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    333	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    401	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    127	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    104	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    52	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    113	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    512	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    487	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)"
    203	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    301	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    594	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    544	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
    403	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    509	"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
    533	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    68	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    464	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    501	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    89	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Administrator; .NET CLR 1.1.4322)"
    456	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    110	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    107	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    101	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    591	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    70	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    563	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    98	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    109	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    112	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    485	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    69	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    468	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    111	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    106	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    405	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    99	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    102	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    373	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    280	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    86	"Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"
    162	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    84	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    201	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    331	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)"
    85	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    95	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    75	"Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.11) Gecko/20050728"
    79	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    254	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    417	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    105	"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
    81	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    87	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    103	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Het Net 4.0; SV1; .NET CLR 1.0.3705)"
    118	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    82	"Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)"
    244	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    78	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705)"
    131	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    91	"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)"
    212	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    339	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705)"
    96	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    92	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    323	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    88	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    80	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    83	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    143	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    422	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    395	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    406	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    234	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    147	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.5))"
    382	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    167	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    319	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    215	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts-MyWay; .NET CLR 1.0.3705)"
    216	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    242	"Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)"
    543	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    498	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    168	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    556	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    290	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    202	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    404	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    230	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    393	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    265	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    211	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    595	"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4"
    268	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    387	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    291	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    383	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    312	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    267	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    266	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    293	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    388	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    392	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    262	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    332	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    253	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    180	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    259	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    289	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    217	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; ZON)"
    121	"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0"
    228	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    288	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    355	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    190	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    135	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    490	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    150	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    235	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    220	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    227	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    465	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    389	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    277	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    421	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
    492	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    321	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    510	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
    292	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    269	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    481	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    172	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    257	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    548	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
    144	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    137	"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.8) Gecko/20050511 Firefox/1.0.4"
    250	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    351	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    249	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    296	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AtHome033)"
    270	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    132	"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; nl-NL; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
    283	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    460	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    445	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    491	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)"
    157	"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
    138	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
    233	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    226	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    263	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    159	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    505	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    261	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    365	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    192	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    181	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705)"
    125	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    322	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    313	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MSOCD; SV1)"
    199	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    386	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    204	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    198	"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)"
    119	"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; nl-nl) AppleWebKit/416.11 (KHTML, like Gecko) Safari/416.12"
    385	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    145	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    545	"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.10) Gecko/20050717 Firefox/1.0.6"
    186	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    384	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; I Wish This Were Firefox.; .NET CLR 1.1.4322)"
    153	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    140	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    225	"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)"
    200	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
    191	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    148	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; provided by huisartsenposten; .NET CLR 1.1.4322)"
    161	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    173	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    170	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    381	"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; nl-nl) AppleWebKit/125.5.5 (KHTML, like Gecko) Safari/125.11"
    166	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
    


  • dogeye schrieb:

    if(sp_pos == ("1.0.3705)",0)!=string::npos)
    

    Wat'n das? Du fragst ab, ob sp_pos gleich Null ist und überprüfst das Ergebnis dieses Vergleichs (FALSE) mit string::npos.
    richtig sollte es wohl so heißen:

    if(zeile.find("1.0.3705)")!=string::npos)
    


  • jo aber so gibt er wenigstens halb richtig alles aus wenn ich zeile find gibt er den kompletten gescannten text aus ...

    sag ja voll seltsamm das muss man sehen was das doofe programm macht ich bin schon total confused!



  • #include <cstdlib>
    #include <iostream>
    #include <fstream>
    #include <string>
    #include "stdio.h"
    
    using namespace std;
    
    int main(int argc, char *argv[])
    
    { 
    
    char fileName[80];
    
    char buffer[255];
    
    char newFileName[80];
    
    cout << "Dateiname: "; // Eingabe Welche Datei gelesen werden soll
    
    cin >> fileName; // Variable für den Dateiname
    
    cout << "Neuer Dateiname: ";
    
    cin >> newFileName;
    
    ifstream fin(fileName); ofstream fout(newFileName);
    
    string zeile;
    
    while(getline(fin, zeile)) //zeilenweise einlesen
    
    {
    
        string::size_type sp_pos = zeile.find("\t");
    
        string nummer = zeile.substr(1,sp_pos); //erster Abschnitt
    
        zeile.erase(0,sp_pos+1);
    
        if(zeile.find("Firefox",0) >= 0)
    
        {
                    zeile = "FireFox";
                    fout << nummer << ' ' << zeile << endl;
    
        }
    
        else if(zeile.find("MSIE",0) >= 0)
    
        {
                zeile = "hallo3";
                fout << nummer << ' ' << zeile << endl;
    
         }
    
         else        fout << nummer << ' ' << zeile << endl;
    
         } 
    
        system("PAUSE");
        return EXIT_SUCCESS;
    
    }
    

    so das ist der aktuelle code! Da funzt das nummern ausgeben und das löschen! Aber ich habe immer noch das problem das er über all die zeile von der 1. If schleife hinschreibt 😕

    auch wenn ich nur nach " 3 " suchen würde und im anderen nach " 1 " schreibt er nur die 1 ifabfrage



  • Mein Tip: Debugger 🙂

    Und nun vergleichst du die Rückgabe von find() mit dem falschen Wert - find() liefert einen size_t (=unsigned irgendwas), der ist auf jeden Fall >=0.



  • und was is dann richtig



  • if(zeile.find(whatever)[b]!=string::npos[/b])
    

    "npos" ist ein definierter Wert in der Stringklasse, den die Such-Funktionen für "nichts gefunden" zurückgeben.



  • das is doch scheisse! Dann heist das ja das er nicht mal die ziffer 1 in der ganzen zeile findet! unmöglich! die is min 5 mal enthalten!!! Aber es wir immer die ganze eingelesene Zeile wieder Ausgegeben! son scheiss!!!
    boeh koennt ausflippen mit dem kack programm da 😞 😞 😞 😞



  • Wenn du die Ziffer '1' suchst, mußt du auch nach '1' suchen und nicht nach "1 " (das wäre eine 1 gefolgt von einem Leerzeichen).

    PS: Ich überlege gerade, dir eine Version auf map-Basis anzubieten :xmas1: Aber ich glaube nicht, daß du damit zurechtkommen würdest



  • denke mal nich 😞 bin n99b.

    Oh man aber wenn ich nach "FireFox" suche is doch normal 'FireFox' geht doch net oda voallem net wenn ich "FireFox 1.0.7" suche


Anmelden zum Antworten