Solved

Question For Alexo = casting to change a void pointer

Posted on 2000-03-21
2
244 Views
Last Modified: 2010-04-15
Alexo,

Does this look right?  I want to assign a pointer the value of a void pointer.  The void pointer is the same structure type as the known pointer:

void PrintOwnerList(struct List *list)
{
// pointer to the ListNode head
struct ListNode *p = list->head;
// used to assign the value of void *RecordPtr
      struct Owner *OwnPtr;

//struct Owner *OwnPtr)p->RecordPtr;

      while(p){
      // assign Owner ptr the value of the void pointer
            OwnPtr = (struct Owner*)p->RecordPtr;
            printf("Last name is %s \n", OwnPtr->Last);
            // advance CurPtr to next ListNode
            p = p->next;
      }
      return;
}

Alexo's respons:

You forgot to set p->RecordPtr = DataPointer on the 1st item.

Thanks!



0
Comment
Question by:John500
2 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 2642241
Have fun!
0
 

Author Comment

by:John500
ID: 2648993
Thanks, I forgot to answer this...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question