Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string.h>
    using namespace std;
    int main()
    {
    try
    {
    char *ptr;
    strcpy(ptr, "Who are u?");
    }
    catch(const exception& excep)
    {
    }
    }
    1. Compilation Error
    2. Who are u?
    3. Runtime Error
    4. segmentation fault
    5. None of these
Correct Option: D

As we are using a pointer value to copy a string, So it will be producing a runtime error.



Your comments will be displayed only after manual approval.