struct Foo

{

char *pName;

char *pAddress;

};

main()

{

struct Foo *obj = malloc(sizeof(struct Foo));

clrscr();

obj->pName = malloc(100);

obj->pAddress = malloc(100);

strcpy(obj->pName,"Your Name");

strcpy(obj->pAddress, "Your Address");

free(obj);

printf("%s", obj->pName);

printf("%s", obj->pAddress);

}

a. Your Name, Your Address

b. Your Address, Your Address

c. Your Name Your Name

d. None of the above

Answers were Sorted based on User's Feedback



struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj =..

Answer / guest

d) printd Nothing, as after free(obj), no memory is there
containing

obj->pName & pbj->pAddress

Is This Answer Correct ?    6 Yes 1 No

struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj =..

Answer / sankara subramanian.n

ya, free(ob); mean free(delete) a previous block of memory .so structure contained item has been deleted

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Code Interview Questions

how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,


What is full form of PEPSI

0 Answers  


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

2 Answers  






Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

1 Answers  


how to test pierrot divisor

0 Answers  


#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers  


main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); } a. “Hello” b. “Hello World” c. “HelloWorld” d. None of the above

4 Answers   Corporate Society, HCL,


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }

1 Answers  


Categories