Computer Science, asked by aryanreddy92, 8 months ago

3. What is the output of the following?
char ptr1[] = "Hello World";
char *ptr2 = malloc( 5 );
ptr2 = ptr1;
What is wrong with the above code (assuming the call to malloc does not fail)?
Pick ONE option
a.There will be a memory overwrite.
b.There will be a segmentation fault.
c.Not enough space is allocated by the malloc.
d.It will not compile in C++.​

Answers

Answered by dhyanishpatel
3

Answer:

(c)

Explanation:

not enough space is allocated by the malloc

Answered by aroranishant799
1

Answer:

The correct answer is option a. There will be a memory overwrite.

Explanation:

  • Overwrite is a word that describes when fresh data or information replaces existing data or information.
  • The name comes from the word overwrite, which means it replaces deleted data with fresh data.
  • Writing a collection of data (binary) in computer data storage, with fresh information to replace the prior information, is the procedure. Overwritten data is often considered unrecoverable.
  • It is not safe to overwrite hard discs. One of the most serious issues with overwriting is the operator's ability to chose not to overwrite all information
  • On the hard disc, thereby ensuring that your security is compromised. Degaussing eliminates the insecurity of choice by destroying all data.

#SPJ2

Similar questions