Skip to main content
gamedev.net
🔒 Locked

Pointer

Started by Tiger99 0 replies 450+ views
Original Post
Tiger99
Tiger99
Hello I am not very familiar with pointer can someone explain what the following two lines are doing register struct _message *memory_block; memory_block = (struct _message *)request_memory_block(); Also, if I need a function to return a pointer, how can I declare the function Thanks
lilFernie
lilFernie
the two lines declare a variable (in a register, incidentally) that will hold the memory address of a structure of type "_message". Then it fills that variable with the value returned from the function "request_memory_block", which is hopefully the memory address of a structure of type "_message"

to create a function that returns a pointer, simply declare it with the return type as a pointer. i.e.

int *function() {}

--- insert signature here ---

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.