Code
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
strcpy(obj->pName,"Your Name");
}
Copyright GeekInterview.com
a. Your Name
b. compile error
c. Name
d. Runtime error
Code
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);
}
Copyright GeekInterview.com
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above
Output of these programs.
a. Your Name
b. compile error
c. Name
d. Runtime error
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above
Questions by hardeep85
Related Answered Questions
Related Open Questions