Ładny brzuch
Mam taki kod :
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("s.txt") ;
ofstream out("k.txt") ;
string s ;
while(getline(in, s)) ;
out << s ;
system("PAUSE");
return 0;
}
Ale on kopiuje mi tylko ostatnia linie(wiersz) tekstu z pliku. Co mam zrobic zeby kopiowal caly takst z pliku ? napewno musze cos wstawic zamiast getline ale co ?
--------------------------------------------------
Linux 2.4.26:::Slackware:::Fluxbox 0.9.10:::X.org:::
Ja chyba widz bd w twoim kodzie :)
#include <iostream> #include <fstream> using namespace std; int main() { ifstream in("s.txt"); ofstream out("k.txt"); string s; while(getline(in, s)) //; out << s; system("PAUSE"); return 0; }
Zakomentowaem rednik wyrniony na czerwono, teraz powinno ju dziaa;)
Kodie
Dzieki, Kodie . Zapomiwalem ze po whlie() si enie stawia ; . THX
--------------------------------------------------
Linux 2.4.26:::Slackware:::Fluxbox 0.9.10:::X.org:::
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("s.txt") ;
ofstream out("k.txt") ;
string s ;
while(getline(in, s)) ;
out << s ;
system("PAUSE");
return 0;
}
Ale on kopiuje mi tylko ostatnia linie(wiersz) tekstu z pliku. Co mam zrobic zeby kopiowal caly takst z pliku ? napewno musze cos wstawic zamiast getline ale co ?
--------------------------------------------------
Linux 2.4.26:::Slackware:::Fluxbox 0.9.10:::X.org:::
Ja chyba widz bd w twoim kodzie :)
#include <iostream> #include <fstream> using namespace std; int main() { ifstream in("s.txt"); ofstream out("k.txt"); string s; while(getline(in, s)) //; out << s; system("PAUSE"); return 0; }
Zakomentowaem rednik wyrniony na czerwono, teraz powinno ju dziaa;)
Kodie
Dzieki, Kodie . Zapomiwalem ze po whlie() si enie stawia ; . THX
--------------------------------------------------
Linux 2.4.26:::Slackware:::Fluxbox 0.9.10:::X.org:::