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

Monday, November 6, 2017

C++ programming language part- 67 String Input


String Input

We have used the get function for one character at a time. But can read a complete string.
code is : get(char *name, int len, char delim=’\n’)

Program 47_1
            //use of get function
            #include
            #include

            void main()
        {
              char p[20];
              cout<< " Type your fullname with family name and press Enter \n";
              cin.get(p,19);
              cout<
            }

Either the code is: getline(char *name, int len, char delim=’\n’)

Program 47_2
            //inherit.demo
            #include
            #include
           
            void main()
        {
            char q[25];
            cout<< "Again type your fullname with family name and press Enter \n";
            cin.getline(q,25);     // getline contains a null cheracter
           cout<

        }


Part- 86 assign the content of twostring


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


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<

            }




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