Click to See Complete Forum and Search --> : Can File Stream being passed like this?


liverbird
September 8th, 2002, 11:04 PM
FILE* fp = fopen(filename,"wb");
if (!fp) return false;
fwrite(&Info, sizeof(SaveInfo), 1, fp);
fwrite(&m_CurrentLevelId, sizeof(m_CurrentLevelId), 1, fp);
GetObject()->Save(fp);
==================================
bool CG3DCObject::Save(FILE* fp){
int i = 100;
if (fwrite(&i, sizeof(i), 1, fp) != 1)
return false;
...
==================================
it crash when the fwrite inside object,
i wonder if file stream pointer can be passed in function like this?
If any one can help me, i will be appreiate d for ur help!!

cup
September 9th, 2002, 02:52 AM
Yes, FILE* can be passed as you have coded it. Can't see anything wrong with the code.

1) Is Info of type SaveInfo?
2) Does GetObject () return a value? Try assigning it to something first and then use that pointer to get to Save.
3) Failing that, it is probably caused by some undetected error which occurred earlier.