txt file lenght
Gey guys could you help me to find the real lenght of a txt file? I mean with all enters , spaces etc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
fstream plik;
bool Ustaw_Plik(){
plik.open("program.txt",ios::in);
if(!plik.is_open()){
return false; }
plik.seekg(0,ios::end);
int dlugosc_pliku =plik.tellg();
char *ciag_znakow=new char[dlugosc_pliku+1];
plik.seekg(0,ios::beg);
plik.read(ciag_znakow,dlugosc_pliku);
plik.close();
ciag_znakow[dlugosc_pliku]=0;
cout<<dlugosc_pliku;
|
Seems ok . but it doesnt always say the truth.
for example.
The txt file contains
// 1234567890enterenterenterenterenterspacespacespacespacespace == 20
But the outpu (dlugosc_pliku) is 27.
Last edited on
Fixed. Enter works as a two characters. Had to find every enter and then decrease dlugosc_pliku.
Topic archived. No new replies allowed.