|
|
how to create a pointer to a pointer?
#341936
09/22/10 02:22
09/22/10 02:22
|
Joined: Sep 2010
Posts: 82
peteredlin
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 82
|
Hello, i am using the following function:
name = ent_create(...,...,...);
Now i wanna use name as string variable containing the name of the entity (pointer)
I cant figure out how to do it
Last edited by peteredlin; 09/22/10 20:50.
|
|
|
Re: how to create a pointer to a pointer?
[Re: Spirit]
#341978
09/22/10 12:52
09/22/10 12:52
|
Joined: Sep 2007
Posts: 62 Germany
bodden
Junior Member
|
Junior Member
Joined: Sep 2007
Posts: 62
Germany
|
@Spirit: You are right. First you have to assign the pointer to something.
But do you know the reason for that? When you assign the pointer to an empty string ("\n", so a 1 Byte cell) and after that you call the str_for_entname, what does happen? Will the entname be copied into some "new" storage cells and the pointer will be reassigned? Or will there be a reallocation of storage cells, the pointer is pointing to, and after that the entname is been copied into that cells? Either way: It seems to make no sense to assign the pointer before using it.
Last edited by bodden; 09/22/10 13:01.
|
|
|
Re: how to create a pointer to a pointer?
[Re: Aku_Aku]
#342034
09/22/10 20:12
09/22/10 20:12
|
Joined: Sep 2010
Posts: 82
peteredlin
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 82
|
Hello , i think i havent explained my problem well anough. Let me try again:
code:
ENTITY* pointer_name;
Now i want to use a string variable for pointer_name, so i can use this single line of code to declare a few ENTITY pointers.
Hope i explained it better.
or a simpler question:How to create a pointer to a pointer.
Last edited by peteredlin; 09/22/10 20:48.
|
|
|
Re: how to create a pointer to a pointer?
[Re: peteredlin]
#342062
09/23/10 02:33
09/23/10 02:33
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
#include <acknex.h>
#include <default.c>
ENTITY* ball;
function create_ent(ENTITY** entpointer)
{
*entpointer = ent_create("p360_frame.mdl",vector(0,0,0),NULL);
}
function main()
{
level_load("small.hmp");
create_ent(ball);
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|