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() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }

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,


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

0 Answers  






What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  


To reverse an entire text file into another text file.... get d file names in cmd line

0 Answers   Subex,


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


How to palindrom string in c language?

6 Answers   Google,


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  


#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }

1 Answers  


Categories