I have a problem with a data table please help.
Problem: I have this 2 .dat files called LFILE & RFILE. LFILE contains some names in an M number of rows.
RFILE contains numerical values that match the names in LFILE, also in M rows. I am to write a function to combine these 2 file’s data and write a new file called LRFILE to the disk. LRFILE must present the above names and matching values in a clean table (height -M rows). I wrote this code but it doesn’t produce the correct result. Help!
example files-----Code://********** #include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; void main() { char* f1name = "LFILE.dat"; char* f2name = "RFILE.dat"; char* f3name = "LRFILE.dat"; ifstream tfile1(f1name, std::ios::in ); ifstream tfile2(f2name, std::ios::in ); ofstream ofile(f3name, std::ios::out); vector <string> f1dat; vector <string> f2dat; char f1str[100]; char f2str[100]; // read while(!tfile1.eof()){ tfile1.getline(f1str,50, '-'); tfile2.getline(f2str,10, '.'); ofile.write(f1str, 50); ofile.write(f2str, 10); } } //*************
================================
LFILE.dat
John Williams (USA)-
Darrell Pace (USA)-
Tomi Poikolainen (Finland)-
Darrell Pace (USA)-
Jay Barrs (USA)Sébastien Flute (France)-
Justin Huish (USA)-
Simon Fairweather (Australia)-
Doreen Wilber (USA)-
Luann Ryon (USA)-
Keto Lossaberidze (USSR)-
Seo Hyang-soon (South Korea)-
Kim Soo-nyung (South Korea)-
Cho Youn-jeong (South Korea)-
Kim Kyung-wook (South Korea)-
Yun Mi-Jin (South Korea)-
=================================
RFILE.dat
1972.
1976.
1980.
1984.
1988.
1992.
1996.
2000.
1992.
1996.
2000.
1972.
1976.
1980.
1984.
============================
These 2 files must combined into a single file as a table.



LinkBack URL
About LinkBacks


