Some confusion about pointers

Posted By: peteredlin

Some confusion about pointers - 12/29/10 16:09

Hi, i am new to pointers and dealing with them..

i got the folliwing code which i cant figure out how to work right:
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>

///////////////////////////////


function Create_ent(ENTITY**ent,char*filename,VECTOR*position)
{
	ent = ent_create(filename,position,NULL);
	

}


ENTITY* box;

function main()
{
 	physX_open();
 	level_load("level.hmp");
 	Create_ent(box,"cube.mdl",vector(0,0,0));
 	box.x=90;
 	
 	
}



I get an error in main called SYS..
I want to load box with the pointer 'ent'
Posted By: Saturnus

Re: Some confusion about pointers - 12/29/10 16:25

You have to dereference your pointer: (notice the asterisk)

*ent = ent_create(filename,position,NULL);
Posted By: peteredlin

Re: Some confusion about pointers - 12/29/10 16:30

Thank you very much

I have one more question about pointers, this has to do with structs.

If i create 2 structs of the same type, and i want to use them for loading a fucntion with variables how must i write that function then? (that one and the same fucntion can work with multiple structs)

Thanks in advance.



© 2024 lite-C Forums