P
pras.vaidya
Hi , below given question was asked to me during an interview and i
figured it out little tricky . It would be a great help if anyone
could solve it.
Code : -
main()
{
char *s1="abcd",*s2=NULL;
/* From here you call a function copy which has return type void .
Simple task is to copy s1 into s2 . */
copy(&s1,&s2);
}
copy(char **s,char **t)
{
----- NORMAL COPY STATEMENTS --------
/* But here we have to malloc " t " compulsory . Now what changes
should i do so that chage will reflect in main .I have to print in main
only. */
}
figured it out little tricky . It would be a great help if anyone
could solve it.
Code : -
main()
{
char *s1="abcd",*s2=NULL;
/* From here you call a function copy which has return type void .
Simple task is to copy s1 into s2 . */
copy(&s1,&s2);
}
copy(char **s,char **t)
{
----- NORMAL COPY STATEMENTS --------
/* But here we have to malloc " t " compulsory . Now what changes
should i do so that chage will reflect in main .I have to print in main
only. */
}