alexa-tracking

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/52e10b53bccb1714508b461c/c-tanya-baca-file-langsung-eof
[C++] tanya :baca file langsung EOF
Code:

#include <math.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cstring>

int main()
{
std::fstream outBuff;
std::string outFile;

outBuff.open("contoh_UT.gpx", std::ios::out);
if(!outBuff){
std::cerr << "Tidak bisa membuat file output. Keluar program...";
std::exit(1);
}

// Program jalan hanya sampai disini????!!@$#E@
// langsung EOF, padahal file masih panjang


while(!outBuff.eof()){
double easting = 123456789, northing = 234567890;
char b, outCari[6]={};
for(int j=0; j<5; j++){
outBuff >> b;
outCari[j] = b;
}

std::cout << "outCari :" << outCari << std::endl;

if(!std::strncmp(outCari, "<trkp", 5)){
outBuff.seekp(7,std::ios::cur);
outBuff << northing << "\" lon=\"" << easting << "\"\>" << std::endl;
}
}
outBuff.close();
return 0;
}


Selamat sore,
tanya gan, ini program ane kenapa ga mau lewat loop while nya ya, test nya pakai eof, tapi sebelum nyampe while loop sudah kondisi eof duluan, minta tolong pencerahannya dong
thks-