know yourselves. information, computer, 7 wonders, various.

Wednesday, November 8, 2017

C++ programming language part- 63 Streams


Streams

A stream is a sourse or destination for collection of character. Streams are two types:  Output streams, allow you to write or store characters and Input streams, allow you to read or fetch characters.
The class  ios is a virtual base class for the istream (Input stream) and ostream (Output stream). The isstream (Input and Output stream) is a class with multiple inheritance from both istream and ostream. The header file contains all of the classes.  

User-define streams

User-define streams are in the form of files. A file is linked to a stream. before a file can be opened, a stream must be obtained.


Stream Classes hierarchies
 



 ifstream-derived from istream, used to file input(reading)
 ofstream-derived from ostream,used for file output (writing)
 fstrean- derived from io stream, used for both





File Input and Output with Integer

The following programs deal with file input and output with respect to using fundamentals and user-define data types. Objects called ofil and Ifil of class ofstream  are created and associated with a file named "int.txt"

Program 46-1
//steam.demo
            #include
             void main()
            {
            ofstream ofil("int.txt");            // object would be any name
            ofil<<12 o:p="">
            }                      // open this text file and watch information from notepad


Program 46_2
            //file output
            #include
            void main()
{ ifstream  ifil("int.txt");     //object would be any name
               int p,q,r;
               ifil>>p;          // like cin
               ifil>>q;
               ifil>>r;
               cout<
            // information from text file named int.txt

File Input and Output with String

Program 46_3
            #include
            void main()
            {
            ofstream nova_sfil("string.txt");
            nova_sfil<<" This is Nova System";
            }
            // open this text file and watch information


Program 46_4
            //file output
            #include
            void main()
            {
            ifstream  sfil("string.txt");     //object would be any name
            char cstr[30];                           // like cin
sfil>>cstr;
            cout<
            }

            // information from text file named int.txt


Part- 86 assign the content of twostring


জ্ঞানকোষ প্রকাশনী
৩৮/২-ক, বাংলাবাজার (২য় তলা), ঢাকা।
       ফোনঃ ৭১১৮৪৪৩, ৮১১২৪৪১, ৮৬২৩২৫১.         
                                                     
কলকাতায় পরিবেশক/প্রাপ্তিস্থান
রিতা ইন্টারন্যাশনাল
৩৬, পি.এন. ব্যানার্জি রোড, কলকাতা
ফোনঃ ২৫১৩৮৩৫৯, ৯৮৩০৪৩৯৬৭৯, +৯১৯৮৩০৪৩৯৬৭৯


Monday, November 6, 2017

C++ programming language part- 64 File Input and Output with abstract data types


File Input and Output with abstract data types

The following programs deal with file input and output using user-define classes. A class called bill is being used for this purpose.

Writing Objects

Program 46_5
            //file input/output
            #include
            class bill
            {  public:
                int bill_no;
                float bill_amt;
            };
            void main()
            { ofstream  bfil_1("bilfile.txt");     //object would be any name
               bill obj1;
               obj1.bill_no=1;
               obj1.bill_amt=125.56;
               bfil_1<







Reading Object

Program 46_6
//file input/output
            #include
            class bill
            {  public:
                int bill_no;
                float bill_amt;
    char bill_str[30];
            };   
            void main()
            {  ifstream bfil_2("bilfile.txt");
               bill obj2;
               bfil_2>>obj2.bill_no>>obj2.bill_amt>>obj2.bill_str;
               cout<<"number= "<
               cout<<"amount= "<
   cout<<" Name= "<


Writing and Reading object together


Program 46_7
{ ofstream  bfil_1("bilfile2.txt");     //object would be any name
               bill obj1;
               obj1.bill_no=1;
               obj1.bill_amt=125.56;
               bfil_1<
           
ifstream bfil_2("bilfile2.txt");
            bill obj2;
            bfil_2>>obj2.bill_no>>obj2.bill_amt;
            cout<<"number= "<
            cout<<"amount= "<

cout<<"Name = "<





জ্ঞানকোষ প্রকাশনী
৩৮/২-ক, বাংলাবাজার (২য় তলা), ঢাকা।
       ফোনঃ ৭১১৮৪৪৩, ৮১১২৪৪১, ৮৬২৩২৫১.         
                                                     
কলকাতায় পরিবেশক/প্রাপ্তিস্থান
রিতা ইন্টারন্যাশনাল
৩৬, পি.এন. ব্যানার্জি রোড, কলকাতা
ফোনঃ ২৫১৩৮৩৫৯, ৯৮৩০৪৩৯৬৭৯, +৯১৯৮৩০৪৩৯৬৭৯