Hello,
I'm learning cpp by trying to translate chunks of my VB6 programs. Of course, I have great missunderstanding of cpp syntax and logic.
Here is example which I cant get to work so please help.
declarations:
Code:
struct n_row
{
char m_name[27];
char m_enable[1];
char m_pointer[6];
char m_crlf[2];
};
const char *myFile = "names.dat";
const short lenRecord = 36;
char *mbuffer[lenRecord];
int allRecords = 43000;
long lof;
int obi;
int brr;
int stt;
functions:
Code:
bool eVFrame::reloadlist(bool gput, int stt, long lof, char mbuffer[lenRecord])
{
int i;
FILE *f;
n_row r;
f=fopen(myFile,"r+b");
if (!f)
return true;
fseek(f, 0, SEEK_END);
lof = ftell(f);
if (stt<1){stt=1;}
for (i=stt;i<=stt;i++)
{
int sz = sizeof(struct n_row);
fseek(f,sz*i,SEEK_SET);
if (!gput)
{
fread(&r,sz,1,f);
}
else
{
fwrite(&r,sz,1,f);
}
}
fclose(f);
return false;
}
int eVFrame::myitems(int obi, int brr)
{
for (int i = obi; i < obi + nRows; i++)
{
eVFrame::reloadlist(false, i, lof, mbuffer[lenRecord]);
wxString mystring(*mbuffer, wxConvUTF8);
wxPuts(mystring);
}
return 0;
}
I call funcion reloadlist from mytems and i cant get data to mbuffer and mystring.
Problem s that I dont know how to assign data to buffer in reloadlist whish I have in r.
Can I load direct from file to buffer[]?