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
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 |
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 |
Is the following code legal? typedef struct a { int x; aType *b; }aType
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0
given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit
Display the time of the system and display the right time of the other country
write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])
write a origram swaoing valu without 3rd variable
main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,