CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Posts
    5

    Question Can File Stream being passed like this?

    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!!

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    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.
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured