I exported an access database to a text file and ensured that each line is of the form:
###############AAAAAAAAAAAAAAAAAAAAAA(variable length comment)
I read in the whole line into whole, and split whole into header (#'s) and comment (A's). From there I try to break up the comment into 70 byte fields and write a record of the form HeaderComment70 (I place header and comment2 into whole and write whole). But it's not writing anything. What did I do wrong?
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in;
in.open("Remark.prn");
if (!in)
{
cout<<"Error opening Remark.prn\n";
return 1;
}
ofstream out;
out.open("Remark1.prn");
if(!out)
{
cout<<"Error opening Remark1.prn\n";
return 1;
}
char header[16]="";
char comment[9970];
char comment2[99870];
char whole[10000]="";
int place=0;
int seq=0;
char foo;
while(!in.eof())
{
in.getline(whole,sizeof(whole));
for(int x=0;x<sizeof(header);x++)
{
header[x]=whole[x];
place=x;
}
for(int x=place;whole[x]!='\n';x++)
comment[place-x]=whole[x];
/*header and comment now separated*/
for(int x=0;x<sizeof(whole);x++)
whole[x]=' ';
place=0;
for(int x=0;foo!='\n';x++)
{
foo=comment[x];
comment2[x-place]=foo;
if(x%69==0)
{
strcat(whole,header);
switch(x)
{
case 69: strcat(whole,"01");
break;
case 138: strcat(whole,"02");
break;
case 207: strcat(whole,"03");
break;
case 276: strcat(whole,"04");
break;
case 245: strcat(whole,"05");
break;
case 414: strcat(whole,"06");
break;
case 483: strcat(whole,"07");
break;
case 552: strcat(whole,"08");
break;
case 621: strcat(whole,"09");
break;
case 690: strcat(whole,"10");
break;
case 759: strcat(whole,"11");
break;
case 828: strcat(whole,"12");
break;
case 897: strcat(whole,"13");
break;
case 966: strcat(whole,"14");
break;
}
strcat(whole,comment2);
strcat(whole,"\n");
place=x;
for(int y=0;x<sizeof(whole);y++)
{
out<<whole[y];
whole[y]=' ';
}
for(int y=0;y<sizeof(comment2);y++)
comment2[y]=' ';
}
}
}
return 0;
}