Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program that provides an example of binary files

Posted By: Nathan Evans     Category: C++ Programming     Views: 6567

Write a program that provides an example of binary files.

Code for Program that provides an example of binary files in C++ Programming

# include <iostream.h>
# include <conio.h>
# include <fstream.h>

class machine
{
    char name[10];
    longint phone;
    public:
    void getdata()
    {
        cout<<"ENTER THE NAME:->";
        cin>>name;
        cout<<"\nENTER THE PHONE NUMBER:->";
        cin>>phone;
    }
    void show()
    {
        cout<<"\nTHE NAME IS:->"<<name;
        cout<<"\nTHE PHONE NUMBER is:->"<<phone;
    }
};

main()
{
machine m;
fstream file;
file.open("data",ios::ate|ios::in|ios::out|ios::binary);
file.seekg(0,ios::beg);

cout<<"\nTHE CONTENTS OF FILE ARE.\n";
while(file.read(char *)&m,sizeof(m))
  
Share: 


Didn't find what you were looking for? Find more on Program that provides an example of binary files Or get search suggestion and latest updates.

Nathan Evans
Nathan Evans author of Program that provides an example of binary files is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!