Home » C++ Programming » Dynamic Memory » Question
  1. What is the output of this program?
    #include <iostream>
    #include <memory>
    #include <string>
    using namespace std;
    int main ()
    {
    pair <string*, ptrdiff_t> Res = get_temporary_buffer<string>(5);
    if (Res.second > 0)
    {
    uninitialized_fill ( Res.first, Res.first + Res.second,
    "Bye " );
    for (int k = 0; k < Res.second; k++)
    cout << Res.first[k] ;
    return_temporary_buffer(Res.first);
    }
    return 0;
    }
    1. Bye
    2. Bye Bye Bye
    3. Bye Bye Bye Bye Bye
    4. Bye Bye
    5. Bye Bye Bye Bye
Correct Option: C

In this program, We storing the string in the string buffer and then we are printing it.



Your comments will be displayed only after manual approval.