N
Nash
Hi,
I have two different files which is filled with data from two
different structures like
struct student
{
char* name;
int age;
};
which is stored in student.dat file and another structure
struct staff
{
char *name,
int age;
int exp;
};
which is stored in staff.dat file. I have to write a function which
should read the first 20 data and write it into sepearate file. I
thought of generalizing the function so i had a function like
enum DATA
{
STUDENT,
STAFF
};
ReadWriteData(void *pData,DATA enData)
{
void * pTempStructArray;
if (enData == STUDENT)
{
pTempStructArray= new student[20];
iSizeOfStruct = sizeof(student);
}
else
{
pTempStructArray= new staff[20];
iSizeOfStruct = sizeof(staff);
}
ReadFile(hFile, &pTempStructArray [0], iSizeOfStruct,
&NumBytesReadWritten, NULL);
}
but the problem is if i try to read the data into this void pointer it
is giving some error like "error C2036: 'void *' : unknown size". Any
idea to generalize this function so that i can used the same function
to copy both the data.
I have two different files which is filled with data from two
different structures like
struct student
{
char* name;
int age;
};
which is stored in student.dat file and another structure
struct staff
{
char *name,
int age;
int exp;
};
which is stored in staff.dat file. I have to write a function which
should read the first 20 data and write it into sepearate file. I
thought of generalizing the function so i had a function like
enum DATA
{
STUDENT,
STAFF
};
ReadWriteData(void *pData,DATA enData)
{
void * pTempStructArray;
if (enData == STUDENT)
{
pTempStructArray= new student[20];
iSizeOfStruct = sizeof(student);
}
else
{
pTempStructArray= new staff[20];
iSizeOfStruct = sizeof(staff);
}
ReadFile(hFile, &pTempStructArray [0], iSizeOfStruct,
&NumBytesReadWritten, NULL);
}
but the problem is if i try to read the data into this void pointer it
is giving some error like "error C2036: 'void *' : unknown size". Any
idea to generalize this function so that i can used the same function
to copy both the data.