Jan 23, 2021, 05:05 AM

News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!


Saving Values in Binary Format

Started by thiruvasagamani, Aug 15, 2008, 04:47 PM

previous topic - next topic
Go Down

thiruvasagamani

To indicate that you want to save a value as binary, when declaring the ofstream variable, specify the ios option as binary.

Here is an example:

Code: [Select]
#include <fstream>
#include <iostream>
using namespace std;

class Student
{
public:
char   FullName[40];
char   CompleteAddress[120];
char   Gender;
double Age;
bool   LivesInASingleParentHome;
};

int main()
{
Student one;

strcpy(one.FullName, "Ernestine Waller");
strcpy(one.CompleteAddress, "824 Larson Drv, Silver Spring, MD 20910");
one.Gender = 'F';
one.Age = 16.50;
one.LivesInASingleParentHome = true;

ofstream ofs("fifthgrade.ros", ios::binary);

return 0;
}
Thiruvasakamani Karnan


nandagopal



nice code and but need explanation mani please post with explanation   



dwarakesh

Hi mani

   I can't understand this particular coding

  ofstream ofs("fifthgrade.ros", ios::binary);

  Can you explain

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Designing Chennai | GinGly :: Build your Personal Website | CineBuzz :: Cinema News | My Kids Diary :: Kids Memories Writing :: Book Website @ 349 Rs monthly
Copyright 2005 - 2020 :: IT Acumens :: All Rights Reserved. :: Sitemap
ITAcumens Discussion Forum with 2 lakhs post running for 15 years - Powered by IT Acumens Dedicated Server