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

#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }

1 Answers  


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


Display the time of the system and display the right time of the other country

1 Answers  


void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }

4 Answers  


why java is platform independent?

13 Answers   Wipro,






Sir... please give some important coding questions asked by product companies..

0 Answers  


#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }

1 Answers  


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


write a origram swaoing valu without 3rd variable

2 Answers  


main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(ā€œ%u %u %u %d \nā€,a,*a,**a,***a); printf(ā€œ%u %u %u %d \nā€,a+1,*a+1,**a+1,***a+1); }

2 Answers  


How we will connect multiple client ? (without using fork,thread)

3 Answers   TelDNA,


Categories