FedFelpato (Normal User)
Newbie
Messaggi: 4
Iscritto: 10/03/2013
|
Ciao a tutti. Stavo realizzando un programmino che copia un file di testo riga per riga e ne cambia alcuni contenuti ma ottengo un outupt indesiderato. Potete aiutarmi??
Ecco il codice:
Codice sorgente - presumibilmente C++ |
#include <iostream> #include <string> #include <fstream> using namespace std; int main(){ ifstream source; ofstream destination; unsigned pos; source.open("source.srt", ios::in); destination.open("destination.srt", ios::app); string riga; do{ getline(source, riga); pos = riga.find("From", pos); if (pos != string::npos){ cout << riga << endl; cout << "pos = " << pos << endl; } destination << riga << endl; } while ((source.eof()==false) && (pos != string::npos)); source.close(); destination.close(); return 0; }
|
Se trova "From" nella stringa la dovrebbe stampare a video e poi stampare la posizione.
Grazie anticipatamente.
|