522 views
0 votes
0 votes
int *x=(int*) malloc(100*sizeof(int));

x=(int*)realloc(x,sizeof(int)*200);

a) If realloc fails then original memory is lost.

b) Nothing realloc is guaranteed to succeed(by returning the original pointer)

c) realloc might throw null pointer exception if malloc fails to allocate memory.

d) calloc should have been used instead of malloc.

1 Answer

1 votes
1 votes

a) If realloc fails, then the original memory is lost 

ithink the qus is wrong it should be

int * x = (int *) malloc(100 * sizeof(int));
x = realloc(x, sizeof(int) * 200);

Related questions

0 votes
0 votes
1 answer
1
Hardik Vagadia asked Jul 26, 2015
638 views
the number of bit strings of length 8 that will either start with 1 or end with 00 is?a) 32              b) 128              c) 160       ...
0 votes
0 votes
1 answer
2
shivani2010 asked Apr 21, 2016
288 views
#include<stdio.h int main() { char arr[10]; memset(arr,0,sizeof(arr)); gets(arr); printf("\n The buffer entered is [%s]\n",arr); return 0; }
3 votes
3 votes
2 answers
3
Himani Srivastava asked Nov 5, 2015
6,638 views
The following code fragment: int x, y= 2, z, a; x= (y* =2) + (z= a =y); printf(&ldquo;%d&rdquo;, x); (a) prints 8(b) prints 6(c) prints 6 or 8 depending on the compile...
1 votes
1 votes
2 answers
4
Umang Raman asked Oct 7, 2015
1,120 views
int main (){ int a=5,b=3; printf("%d", a+++++b); // 5 +'s }Please Explain.