Hi, i was trying to use the fstream library to create a programme that serves someworth like a data base i.e it stores some information that will be used in the shortest possible time but the problem is that it does not work for me does any one have an idea?

Recommended Answers

All 6 Replies

Post code. We are not clarvoyant and I don't have my crystal ball with me.

My question is can any body show me how to do that...

Here's a guess

struct some_stuff
{
   int x;
   int y;
   char name[255];
};

int main()
{
   some_stuff data;
   ofstream out("filenam.dat", ios::binary);
   if( out.is_open() )
   {
       out.write((char *)&data, sizeof(data));
       out.close();
   }
}

thanks, that worked fine but how can i get access to the file after writing it.

access the file with what? If you want to read the data back then just open the ifstream for input and call its read() method.

If you mean how to read the file with another program like Notepad.exe -- they can't.

Thanks men that does it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.