how do i loop until this is done?
the way it is written currently, it only writes the first 512 characters. how can i make it loop until it writes the whole file? i think i need some kind of loop in my writer code section where i have set up the while loop that i dont know how to fill in. any ideas?
//reader
Code:#include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { cout << "in reader" << endl; char readbuffer[512]; int ipipe = atoi(argv[2]); ifstream ifs(argv[1]); while (!ifs.eof()) { ifs.read(readbuffer, sizeof(readbuffer)); write(ipipe, readbuffer, ifs.gcount()); } close(ipipe); return 0; }
//writer
Code:#include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { cout << "in writer" << endl; char writebuffer[512]; int rc; int ipipe = atoi(argv[2]); ofstream ofs(argv[1]); while (?) { rc = read(ipipe, writebuffer, sizeof(writebuffer)); ofs.write(writebuffer, rc); } close(ipipe); return 0; }



LinkBack URL
About LinkBacks



