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

Monday, November 6, 2017

C++ programming language part- 68 Integer Input and Output


Integer Input and Output

While get and put can be used for character, the read and write can be used for numeric value. The read function has to be called by the address of the buffer and the size of the buffer. The write and read function works the same way.
Note: The process of type cast is  int a; char b[5]; b=(char*) &a;

Program 47_3
            //write function.demo
            #include
            #include

            void main()
            {
              ofstream ofil("Whisper.txt");
              int p=0;
              cin>>p;
              ofil.write((char*) &p,sizeof(p)); }     // The (char*) is a type cast

 Program 47_4
//read function.demo
            #include
            #include

            void main()
            {
              ifstream ifil("Whisper.txt");
              int p=0;
              ifil.read((char*)&p,sizeof(p));
              cout<
        }

File Opening

Program 47_5
            void main()
        {
             ifstream ifil;
            char q[20];
             ifil.open("careless.txt");
             ifil>>q;
              cout<

            }




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

C++ programming language part- 69 File Pointers


File Pointers

The C++ input and output system manages two integer values associated with a file. One is the get pointer, which specifies where in the file the next input or read operation will occur. the other is the put pointer,  which specifies where in the file the next output or write operation will occur. The seekg() and tellg() functions allow you to set and examine the get pointer, and seekp() and tellp() function perform these same actions on the put pointer.

The tellg() and tellp() can be used to find out the current position of the file pointer in the file. The seekg() member function takes two arguments. Suppose: Fil.seekg(10, ios::beg) means , "position the get pointer 10 bytes from the biginning of the file". The first argument is an integer specify the number also called offset . There are three referance points defined on the ios class.
@  ios::beg - the beginning of the file
@  ios::cur - the current position of the file pointer
@  ios::end - the end of the file

consider the following program, which finds out the member of records in the a file.



Program 47_6
           
            class bill
            {
              public:
                int bill_no;
                float bill_amt;
            };
       
            void main()

            {
            bill obj;
            fstream  bfil("bilfile.txt",ios::in);     // ask your faculty about fstream and o/ifstream
            bfil.seekg(0,ios::end);
            int end;
            end=bfil.tellg();
            cout<<"The size of the file is "<
            cout<<"Size of one record is "<
            int No_rce=end/sizeof(bill);
            cout<<"There are "<

        }




Part- 86 assign the content of twostring


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