struct Foo

{

char *pName;

};

main()

{

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

clrscr();

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

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

}

a. Your Name

b. compile error

c. Name

d. Runtime error

Answers were Sorted based on User's Feedback



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

Answer / ameo

runtime error.

pName is not allocated.

Is This Answer Correct ?    5 Yes 0 No

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

Answer / guest

a)

Is This Answer Correct ?    1 Yes 3 No

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

Answer / shrikantauti

Your Name

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Code Interview Questions

void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }

2 Answers  


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

3 Answers  


main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }

1 Answers  






what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


plz send me all data structure related programs

2 Answers  


main() { int i=5,j=10; i=i&=j&&10; printf("%d %d",i,j); }

1 Answers  


main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513

3 Answers   HCL, Logical Computers,


what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


Is the following code legal? struct a { int x; struct a *b; }

2 Answers  


Categories