Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
int main()
5.
{
6.
try
7.
{
8.
char *p;
9.
strcpy(p, "How r u");
10.
}
11.
catch(const exception& er)
12.
{
13.
}
14.
}
Options:
A .  How r u
B .  segmentation fault
C .  error
D .  runtime error
Answer: Option B

As we are using a pointer value to copy a string, So it will be producing a runtime error.
Output:
$ g++ res3.cpp
$ a.out
segmentation fault



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers