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 Program that Inputs 10 Numbers in an Array and Show the Maximum Number

2 Answers   Ace Info,


How to reverse a String without using C functions ?

33 Answers   Matrix, TCS, Wipro,


main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }

1 Answers  


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  






Find the largest number in a binary tree

7 Answers   Infosys,


There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.

1 Answers   Nagarro,


plz send me all data structure related programs

2 Answers  


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

1 Answers  


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

0 Answers  


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

2 Answers   HCL,


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

3 Answers   HCL,


Categories