Question
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.
}
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.
}
Answer: Option B
Was this answer helpful ?
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 ?
More Questions on This Topic :
Question 4.
When we call that resource is leaked?
....
Submit Solution