Click here to Skip to main content
15,898,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: LPT Listener using thread Pin
JudyL_MD28-Sep-07 1:59
JudyL_MD28-Sep-07 1:59 
GeneralRe: LPT Listener using thread Pin
JudyL_MD28-Sep-07 2:03
JudyL_MD28-Sep-07 2:03 
AnswerRe: LPT Listener using thread Pin
David Crow27-Sep-07 3:30
David Crow27-Sep-07 3:30 
AnswerRe: LPT Listener using thread Pin
Rahul Vaishnav2-Oct-07 20:07
Rahul Vaishnav2-Oct-07 20:07 
Questiona pointer Pin
youbo26-Sep-07 21:01
youbo26-Sep-07 21:01 
AnswerRe: a pointer Pin
youbo26-Sep-07 21:31
youbo26-Sep-07 21:31 
GeneralRe: a pointer Pin
toxcct26-Sep-07 21:39
toxcct26-Sep-07 21:39 
AnswerRe: a pointer Pin
toxcct26-Sep-07 21:35
toxcct26-Sep-07 21:35 
Mister youbo,

i'm goin to answer you, but before, here some comments i have to say to you, which i want you to take from the good, wise side...

you've been asking several question like this one, which are obviously from a beginner. You still can ask when you don't understand, but a better solution would be to learn the C/C++ languages a bit deeper to get rid of these by yourself.

ok then, let's go:

youbo wrote:
node->next = (struct ListEntry *) malloc(sizeof(struct ListEntry));


it seems to me that you have a linked list, and that you code in C (correct me if i'm wrong).
a linked list is compound of nodes; each node stores a value, and has a link (pointer) to the node next to it in the list.

for what i understand here, node might be defined as a struct (ListEntry), and next is defined inside it to being a pointer to another node (ListEntry*).

for the right par of the assignment operator, we have a call the the malloc() function.

malloc() is used to allocate memory dynamically on the heap. you give it an integer parameter which tells it the amount of memory to allocate. here, sizeof(struct ListEntry); that mean, "allocate the amount which a ListEntry structure regularly takes in memory".

then, as malloc() returns a void* (a pointer to anything), we must translate it to the type of pointer which will store the returned value, by using a cast operation. that's performed with the (struct ListEntry*) prepending the malloc call.

then, once the memory is allocated, the address of that memory is returned, and casted to the type of a "pointer to a node in the list", we can assign this to the next member of the node struct (thus the syntax node->next)

any more questions ?


GeneralRe: a pointer Pin
John R. Shaw26-Sep-07 21:52
John R. Shaw26-Sep-07 21:52 
GeneralRe: a pointer Pin
toxcct26-Sep-07 21:54
toxcct26-Sep-07 21:54 
GeneralRe: a pointer Pin
John R. Shaw26-Sep-07 23:12
John R. Shaw26-Sep-07 23:12 
AnswerRe: a pointer Pin
baerten26-Sep-07 21:37
baerten26-Sep-07 21:37 
GeneralRe: a pointer Pin
youbo26-Sep-07 21:45
youbo26-Sep-07 21:45 
GeneralRe: a pointer [modified] Pin
Russell'26-Sep-07 22:29
Russell'26-Sep-07 22:29 
GeneralRe: a pointer Pin
toxcct26-Sep-07 22:44
toxcct26-Sep-07 22:44 
GeneralRe: a pointer Pin
Russell'26-Sep-07 22:56
Russell'26-Sep-07 22:56 
QuestionUrgent - How to identify given image is too dark or light Pin
sujtha26-Sep-07 20:51
sujtha26-Sep-07 20:51 
AnswerRe: Urgent - How to identify given image is too dark or light Pin
Waldermort26-Sep-07 21:00
Waldermort26-Sep-07 21:00 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
toxcct26-Sep-07 22:48
toxcct26-Sep-07 22:48 
AnswerRe: Urgent - How to identify given image is too dark or light Pin
Russell'26-Sep-07 22:37
Russell'26-Sep-07 22:37 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
Nishad S27-Sep-07 1:56
Nishad S27-Sep-07 1:56 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
Russell'27-Sep-07 2:14
Russell'27-Sep-07 2:14 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
Nishad S27-Sep-07 3:06
Nishad S27-Sep-07 3:06 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
Russell'27-Sep-07 3:38
Russell'27-Sep-07 3:38 
GeneralRe: Urgent - How to identify given image is too dark or light Pin
Sreedhar DV27-Sep-07 23:02
Sreedhar DV27-Sep-07 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.