SlideShare a Scribd company logo
/*Q.12 Given a binary file PHONE.DAT, containing records of the following structure type-:
class phonlist
  {
     char Name[20] ;
     char Address[30] ;
     char AreaCode[5] ;
    char phoneNo[15] ;
    public :
    void Register();
    void show();
    };
Write a function TRANSFER() in C++, that would copy all those records which are having
AreaCode as "DEL" from PHONE.DAT to PHONBACK.DAT.           */



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

class phonelist
  {
    char name[20] ;
    char address[30] ;
    char areacode[5] ;
    char phoneno[15] ;

public :

    void reg()
     {

     cout<<"enter name : ";
     gets(name);
     cout<<"enter address : ";
     gets(address);
     cout<<"enter areacode : ";
     gets(areacode);
     cout<<"enter phone number : ";
     gets(phoneno);
}

     void show()
    {
cout<<"enter name : ";
      cout<<"enter address : ";
      cout<<"enter areacode : ";
      cout<<"enter phone number : ";

  }

  char* return_code()
  {
   return areacode;
  }

 }p[5] ;



 void main()
 {
 phonelist temp;
 int n,i;
      cout<<"for how many people you wish to enter the details ";
      cin>>n;

  ofstream fout;
  fout.open("phone.dat",ios::binary);
                           //writing in phone.dat
   for(i=0;i<n;i++)
      {
         p[i].reg();
         fout.write((char*)&p[i],sizeof(phonelist));

        }




   ifstream fin;
   fin.open("phone.dat",ios::binary);




fin.open("phone.dat",ios::binary);
   fout.open("phoneback.dat",ios::binary);
                          //transferring records with del areacode to phoneback.dat
i=0;
       while(fin)
         {
           fin.read((char*)&temp,sizeof(phonelist));

              if(strcmp("del",p[i].return_code())==0)
                  {
                     fout.write((char*)&temp,sizeof(phonelist));
                     i++;
                   }
          }
                   //displaying the records in phoneback.dat
      fin.open("phoneback.dat",ios::binary);

      while(fin)
       {
        fin.read((char*)&temp,sizeof(phonelist));
        temp.show();
        }



   fin.close();
   fout.close();

   getch();

  }




/*Q.11 Write a program in C++ to transfer a particular type of stock from the file "stock.dat" to
another file "Site.dat". Assuming that the binary file is containing the records of following
structure:
struct Products
{
   int id;
   char Iname[30];
   int type;
};
   Remember that transfer means deletion from the "stock.dat" file and addition in the "site.dat"
     file.
*/



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

struct products
  {
     int id;
    char iname[30];
    int type;
   };



void main()
{
  products p[5],temp;
  int n,t,i;



cout<<"for how many products you wish to enter information ";
cin>>n;




ofstream fout;

 fout.open("stock.dat",ios::binary);



         //entering the details in stock file



for(i=0;i<n;i++)
 {
   cout<<"enter id : ";
   cin>>p[i].id;
   cout<<"enter name : ";
   gets(p[i].iname);
cout<<"enter type : ";
      cin>>p[i].type;

 fout.write((char*)&p[i],sizeof(products));
 }
   fout.close();



 cout<<"which type of stock you wish to transfer to other file ";
 cin>>t;

 ifstream fin;

 fin.open("stock.dat",ios::binary);
 fout.open("site.dat",ios::binary);

  i=0;




//loop to transfer the specified records in site file



while(fin)
 {
  fin.read((char*)&temp,sizeof(products));

       if(p[i].type==t)
             fout.write((char*)&temp,sizeof(products));
              i++;
  }




 fin.close();
   fout.close();

  remove("stock.dat");



   fin.open("site.dat",ios::binary);
while(fin)
    {
     fin.read((char*)&temp,sizeof(products));

         cout<<" id : "<<temp.id;
         cout<<"n name : "<<temp.iname;
         cout<<"n type : "<<temp.type;

     }

fin.close();

    getch();
}

More Related Content

What's hot

1
11
C++ programs
C++ programsC++ programs
C++ programs
Mukund Gandrakota
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
khasmanjalali
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
Muhammad Ulhaque
 
Introduction to F# for the C# developer
Introduction to F# for the C# developerIntroduction to F# for the C# developer
Introduction to F# for the C# developer
njpst8
 
Computer hw1
Computer hw1Computer hw1
Computer hw1
Dũng Nguyễn Đức
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
ilsamaryum
 
C++ file
C++ fileC++ file
C++ file
Mukund Trivedi
 
Sol7
Sol7Sol7
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Qno 1 (b)
Qno 1 (b)Qno 1 (b)
Cs project
Cs projectCs project
Cs project
Dhairya Pant
 
Hotel Management In C++
Hotel Management In C++Hotel Management In C++
Hotel Management In C++
Amish Mhatre
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
Karan Bora
 
Class array
Class arrayClass array
Class array
nky92
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
Sushil Mishra
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
Sayantan Sur
 

What's hot (19)

1
11
1
 
C++ programs
C++ programsC++ programs
C++ programs
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 
Introduction to F# for the C# developer
Introduction to F# for the C# developerIntroduction to F# for the C# developer
Introduction to F# for the C# developer
 
Computer hw1
Computer hw1Computer hw1
Computer hw1
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
C++ file
C++ fileC++ file
C++ file
 
Sol7
Sol7Sol7
Sol7
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Qno 1 (b)
Qno 1 (b)Qno 1 (b)
Qno 1 (b)
 
Cs project
Cs projectCs project
Cs project
 
Hotel Management In C++
Hotel Management In C++Hotel Management In C++
Hotel Management In C++
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
 
Class array
Class arrayClass array
Class array
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 

Viewers also liked

brain gain
brain gainbrain gain
brain gain
sanskriti yadav
 
Descriptive text ^ ^
Descriptive text ^ ^Descriptive text ^ ^
Descriptive text ^ ^
Faizal Imam Dharmawan
 
Hukum Perkawinan Adat
Hukum Perkawinan AdatHukum Perkawinan Adat
Hukum Perkawinan Adat
Faizal Imam Dharmawan
 
Sintaksis
SintaksisSintaksis
Sintaksis
Devi Seftiana
 
Unsur Unsur Transisi Fisika
Unsur Unsur Transisi FisikaUnsur Unsur Transisi Fisika
Unsur Unsur Transisi Fisika
Faizal Imam Dharmawan
 
Letak bilangan pada garis bilangan
Letak bilangan pada garis bilanganLetak bilangan pada garis bilangan
Letak bilangan pada garis bilangan
Devi Seftiana
 
Teori perkembangan muka bumi
Teori perkembangan muka bumiTeori perkembangan muka bumi
Teori perkembangan muka bumi
Devi Seftiana
 
Sistem Ekonomi Campuran
Sistem Ekonomi CampuranSistem Ekonomi Campuran
Sistem Ekonomi Campuran
Devi Seftiana
 
City of Moore Parks Master Plan 2012
City of Moore Parks Master Plan 2012City of Moore Parks Master Plan 2012
City of Moore Parks Master Plan 2012
cityofmoore
 
Biologi sel
Biologi selBiologi sel
استارتاپ و حومه
استارتاپ و حومهاستارتاپ و حومه
استارتاپ و حومه
mohammad zahedi
 
(3) signos pureba 1
(3) signos pureba 1(3) signos pureba 1
(3) signos pureba 1monthe08
 
Kolorki. ;)))
Kolorki. ;)))Kolorki. ;)))
Kolorki. ;)))
Nadi_ne
 
Kolory-stardolla
Kolory-stardollaKolory-stardolla
Kolory-stardollaNadi_ne
 
Indices tecnologia ii imprimir
Indices tecnologia ii imprimirIndices tecnologia ii imprimir
Indices tecnologia ii imprimir
Liset Ramírez Díaz
 

Viewers also liked (16)

brain gain
brain gainbrain gain
brain gain
 
koperasi
koperasikoperasi
koperasi
 
Descriptive text ^ ^
Descriptive text ^ ^Descriptive text ^ ^
Descriptive text ^ ^
 
Hukum Perkawinan Adat
Hukum Perkawinan AdatHukum Perkawinan Adat
Hukum Perkawinan Adat
 
Sintaksis
SintaksisSintaksis
Sintaksis
 
Unsur Unsur Transisi Fisika
Unsur Unsur Transisi FisikaUnsur Unsur Transisi Fisika
Unsur Unsur Transisi Fisika
 
Letak bilangan pada garis bilangan
Letak bilangan pada garis bilanganLetak bilangan pada garis bilangan
Letak bilangan pada garis bilangan
 
Teori perkembangan muka bumi
Teori perkembangan muka bumiTeori perkembangan muka bumi
Teori perkembangan muka bumi
 
Sistem Ekonomi Campuran
Sistem Ekonomi CampuranSistem Ekonomi Campuran
Sistem Ekonomi Campuran
 
City of Moore Parks Master Plan 2012
City of Moore Parks Master Plan 2012City of Moore Parks Master Plan 2012
City of Moore Parks Master Plan 2012
 
Biologi sel
Biologi selBiologi sel
Biologi sel
 
استارتاپ و حومه
استارتاپ و حومهاستارتاپ و حومه
استارتاپ و حومه
 
(3) signos pureba 1
(3) signos pureba 1(3) signos pureba 1
(3) signos pureba 1
 
Kolorki. ;)))
Kolorki. ;)))Kolorki. ;)))
Kolorki. ;)))
 
Kolory-stardolla
Kolory-stardollaKolory-stardolla
Kolory-stardolla
 
Indices tecnologia ii imprimir
Indices tecnologia ii imprimirIndices tecnologia ii imprimir
Indices tecnologia ii imprimir
 

Similar to Cmptr ass

Railway reservation
Railway reservationRailway reservation
Railway reservation
Swarup Boro
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
Files
FilesFiles
File Handling Program
File Handling ProgramFile Handling Program
File handling complete programs in c++
File handling complete programs in c++File handling complete programs in c++
File handling complete programs in c++
zain ul hassan
 
Data structures
Data structuresData structures
Data structures
gayatrigayu1
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
Arsh Vishwakarma
 
Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docx
rennaknapp
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
Dr .Ahmed Tawwab
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
annucommunication1
 
num.txt(Save this file under D Drive.Then the path of the file is D.pdf
num.txt(Save this file under D Drive.Then the path of the file is D.pdfnum.txt(Save this file under D Drive.Then the path of the file is D.pdf
num.txt(Save this file under D Drive.Then the path of the file is D.pdf
ANSAPPARELS
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
Daniel Nyagechi
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
Ahmed Mekkawy
 
Exmaples of file handling
Exmaples of file handlingExmaples of file handling
Exmaples of file handling
sparkishpearl
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
Krishna Raj
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
rahulchamp2345
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into it
melakusisay507
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
Deepak Singh
 
C s investigatory project on telephone directory
C s  investigatory project on telephone directoryC s  investigatory project on telephone directory
C s investigatory project on telephone directory
SHUBHAM YADAV
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
SANDEEPARIHANT
 

Similar to Cmptr ass (20)

Railway reservation
Railway reservationRailway reservation
Railway reservation
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Files
FilesFiles
Files
 
File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
File handling complete programs in c++
File handling complete programs in c++File handling complete programs in c++
File handling complete programs in c++
 
Data structures
Data structuresData structures
Data structures
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docx
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
num.txt(Save this file under D Drive.Then the path of the file is D.pdf
num.txt(Save this file under D Drive.Then the path of the file is D.pdfnum.txt(Save this file under D Drive.Then the path of the file is D.pdf
num.txt(Save this file under D Drive.Then the path of the file is D.pdf
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Exmaples of file handling
Exmaples of file handlingExmaples of file handling
Exmaples of file handling
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into it
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
 
C s investigatory project on telephone directory
C s  investigatory project on telephone directoryC s  investigatory project on telephone directory
C s investigatory project on telephone directory
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 

Recently uploaded

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 

Recently uploaded (20)

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 

Cmptr ass

  • 1. /*Q.12 Given a binary file PHONE.DAT, containing records of the following structure type-: class phonlist { char Name[20] ; char Address[30] ; char AreaCode[5] ; char phoneNo[15] ; public : void Register(); void show(); }; Write a function TRANSFER() in C++, that would copy all those records which are having AreaCode as "DEL" from PHONE.DAT to PHONBACK.DAT. */ #include<iostream.h> #include<conio.h> #include<stdio.h> #include<fstream.h> #include<string.h> class phonelist { char name[20] ; char address[30] ; char areacode[5] ; char phoneno[15] ; public : void reg() { cout<<"enter name : "; gets(name); cout<<"enter address : "; gets(address); cout<<"enter areacode : "; gets(areacode); cout<<"enter phone number : "; gets(phoneno); } void show() {
  • 2. cout<<"enter name : "; cout<<"enter address : "; cout<<"enter areacode : "; cout<<"enter phone number : "; } char* return_code() { return areacode; } }p[5] ; void main() { phonelist temp; int n,i; cout<<"for how many people you wish to enter the details "; cin>>n; ofstream fout; fout.open("phone.dat",ios::binary); //writing in phone.dat for(i=0;i<n;i++) { p[i].reg(); fout.write((char*)&p[i],sizeof(phonelist)); } ifstream fin; fin.open("phone.dat",ios::binary); fin.open("phone.dat",ios::binary); fout.open("phoneback.dat",ios::binary); //transferring records with del areacode to phoneback.dat
  • 3. i=0; while(fin) { fin.read((char*)&temp,sizeof(phonelist)); if(strcmp("del",p[i].return_code())==0) { fout.write((char*)&temp,sizeof(phonelist)); i++; } } //displaying the records in phoneback.dat fin.open("phoneback.dat",ios::binary); while(fin) { fin.read((char*)&temp,sizeof(phonelist)); temp.show(); } fin.close(); fout.close(); getch(); } /*Q.11 Write a program in C++ to transfer a particular type of stock from the file "stock.dat" to another file "Site.dat". Assuming that the binary file is containing the records of following structure: struct Products { int id; char Iname[30]; int type; }; Remember that transfer means deletion from the "stock.dat" file and addition in the "site.dat" file.
  • 4. */ #include<iostream.h> #include<conio.h> #include<stdio.h> #include<fstream.h> struct products { int id; char iname[30]; int type; }; void main() { products p[5],temp; int n,t,i; cout<<"for how many products you wish to enter information "; cin>>n; ofstream fout; fout.open("stock.dat",ios::binary); //entering the details in stock file for(i=0;i<n;i++) { cout<<"enter id : "; cin>>p[i].id; cout<<"enter name : "; gets(p[i].iname);
  • 5. cout<<"enter type : "; cin>>p[i].type; fout.write((char*)&p[i],sizeof(products)); } fout.close(); cout<<"which type of stock you wish to transfer to other file "; cin>>t; ifstream fin; fin.open("stock.dat",ios::binary); fout.open("site.dat",ios::binary); i=0; //loop to transfer the specified records in site file while(fin) { fin.read((char*)&temp,sizeof(products)); if(p[i].type==t) fout.write((char*)&temp,sizeof(products)); i++; } fin.close(); fout.close(); remove("stock.dat"); fin.open("site.dat",ios::binary);
  • 6. while(fin) { fin.read((char*)&temp,sizeof(products)); cout<<" id : "<<temp.id; cout<<"n name : "<<temp.iname; cout<<"n type : "<<temp.type; } fin.close(); getch(); }