-
What is the output of this program?
#include
using namespace std;
int main()
{
char* buffer;
try
{
buffer = new char[1024];
if (buffer == 0)
throw "Memory allocation failure!";
else
cout << sizeof(buffer) <<" " << "Byte successfully allocated!"<
}
catch(char *strg)
{
cout<<"Exception raised: "<}
return 0;
}
-
- Depends on the size of the data type
- 4 Bytes allocated successfully
- 8 Byte successfully allocated!
- Memory allocation failure
- None of these
Correct Option: A
As we are allocating the memory to the variables and if there are not sufficient size means, it will throw an exception.