writing into binary file

Discussion in 'C++' started by senthamizh, Aug 31, 2010.

  1. senthamizh

    senthamizh New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have a problem when i am writing into files in a binary format.I have noticed that, it writes two times into the file. Here i have attached the code.


    Code:
    class bank
    {
    protected:
    char receive[20];
    public:
    }
    
    int main()
    {
    fstream file;
    strcpy(receive,"hello");
    file.open("binary.my",ios_base::in | ios_base::out | ios_base::binary | ios_base::app);
    file.write(reinterpret_cast(&receive),sizeof(receive));
    file.close();
    return 0;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice