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

write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


can u give me the c codings for converting a string into the hexa decimal form......

1 Answers  


Who could write how to find a prime number in dynamic array?

1 Answers  


plz send me all data structure related programs

2 Answers  


Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?

0 Answers  






#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


Derive expression for converting RGB color parameters to HSV values

1 Answers  


source code for delete data in array for c

1 Answers   TCS,


program to find the roots of a quadratic equation

14 Answers   College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  


find A^B using Recursive function

2 Answers  


main() { char not; not=!2; printf("%d",not); }

1 Answers  


Categories