cak9empol
TS
cak9empol
[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:/:o/ut);
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-
0
470
0
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Mari bergabung, dapatkan informasi dan teman baru!
Programmer Forum
Programmer Forum
icon
20.2KThread4.2KAnggota
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Ikuti KASKUS di
© 2023 KASKUS, PT Darta Media Indonesia. All rights reserved.