Thursday, May 24, 2007

If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

10 comments:

Unknown said...

Vijay.

Thanks for posting your collection of interview questions and solutions. They have helped me clarify a number of concepts and prepare for technical interviews.

It really helps to read your entire approach and learn how you arrive at a particular solution.

Keep up the great work. And once again, Thanks.

Prateek said...

very helpful dude...its good to find all the good questions at one place..

Anonymous said...

Very useful questions and answeres.
Thanks for providing everything together

Anonymous said...

very good robert very good

Anonymous said...

Fundoo questions and answers - thanks a lot for posting such a wonderful collection. BTW - a bit more explanation to few question will be more useful (e.g. generic link list ).

ravindra said...

fsdfs

ravindra said...

#include stdio.h

void trim1(char s[]);

int main()
{
char str1[]=" Hello I am Good ";
clrscr();
printf("\n\nBefore trimming : [%s]", str1);
printf("\n\nAfter trimming "); trim1(str1);

getch();
return 0;
}


void trim1(char s[])
{
char ps[50];
int i,j=0;
for (i=0; s[i] != '\0'; i++)
{
if (!isspace(s[i]))
{
ps[j++] = s[i];
}
}
ps[j] = '\0';
printf("[ ");
for(j=0;j<-strlen(ps);j++)
printf("%c",ps[j]);
printf(" ]");
}

ravindra said...

without using pointer in trim function

Anonymous said...

thanks a lot for posting such a good collection of questions, I really appreciate the effort you have put in.

Regards

Anonymous said...

Thanks a lot for all your effort, I have referred o your blog every time I prepare for interviews. Thanks again for your effort, I appreciate that.