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:

  1. 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.

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

    ReplyDelete
  3. Very useful questions and answeres.
    Thanks for providing everything together

    ReplyDelete
  4. very good robert very good

    ReplyDelete
  5. 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 ).

    ReplyDelete
  6. #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(" ]");
    }

    ReplyDelete
  7. without using pointer in trim function

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

    Regards

    ReplyDelete
  9. 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.

    ReplyDelete