#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
string line;
ifstream myfile;
ofstream myfile2, myfile3;
myfile.open("input.txt");
myfile2.open("output.txt");
myfile3.open("logfile.txt");
myfile2<<"column1\t\t"<<"column2\t\t"<<column3<<endl;
while(getline(myfile,line)
{
stringstream ss(line);
ss.clear();
int x[20],y,z,hours,minutes,index;
char colon;
double seconds;
string junk;
string word1;
if(ss>> hours>>colon>>minutes>>colon>>seconds && colon==':')
{
myfile3<<"success reading time code\n";
myfile<<hours<<":"<<minutes<<":"<<seconds<<endl;
ss<<"";
ss.clear();
}
else if(ss>>index>>colon>>hex>>x[0]>>hex>>x[1]>>hex>>x[2]>>hex>>x[3]>>hex>>x[4]>>hex>>x[5]>>hex>>x[6]>>hex>>x[7]>>hex>>x[8]>>hex>>x[9]>>hex>>x[10]>>hex>>x[11]>>hex>>x[12]>>hex>>x[13]>>hex>>x[14]>>hex>>x[15]>>hex>>x[16]>>hex>>x[17]>>hex>>x[18]>>hex>>x[19] && colon==":")
{
myfile3<<"success reading hex code line\n";
myfile2<<x[0]<<endl;
ss<<"";
ss.clear();
}
else{
myfile3<<"error"<<endl;
ss<<"";
ss.clear();
}
}
myfile.close();
myfile2.close();
myfile3.close();
return0
}
|