hello frndzz...
just wrote a piece of code in c++....bt this didnt create any .DAT file as expected.....dun knw wats wrng....

#include<fstream>
#include<iostream>
using namespace std;
class person
{
      int age;
      char name[40];
      public:
             void get()
             {
                  cout<<"enter age:";
                  cin>>age;
                  cout<<"enter name:";
                  cin>>name;
             }
             void show()
             {
                  cout<<"age is:"<<age<<endl;
                  cout<<"name is:"<<name<<endl;
             }
};
int main()
{
    fstream file;
    person pers;
    char ch;
    file.open("asssd.DAT",ios::app|ios::out|ios::in|ios::binary);
    do
    {
                pers.get();
                file.write(reinterpret_cast<char*>(&pers),sizeof(pers)); 
                cout<<"do another:";
                cin>>ch;                                             
    }while(ch=='y');

      system("pause");
    return 0;
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Please use 'code' tags instead of 'program' tags.

Also, please use real words instead of "frndzz, bt, dun knw wats wrng".

This question has already been answered. Start a new discussion instead.