Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,507 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
pointers is my nightmare #268678
05/30/09 16:11
05/30/09 16:11
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline OP
Member
XD1v0  Offline OP
Member

Joined: Jun 2008
Posts: 151
Ukraine
I try allocate memory for multidimension struct but do this in function, and that function get pointer as parameter.
Some like this(dont work)
Code:
typedef struct {short f[3];} MFACES;
MFACES* fbuf[100];
 function create_stuct_array (MFACES* arr,var num)
{
	arr = malloc (sizeof(MFACES)*num);memset(arr,16,sizeof(MFACES)*num);
	return (sizeof(MFACES)*num);
}
void main ()
{
 res = create_stuct_array (fbuf[3],100);
 file_save ("result.txt",fbuf[3],res);
}

i know how allocate direct for pointer
Code:
	fbuf[3] = malloc (sizeof(MFACES)*100);memset(fbuf[3],16,sizeof(MFACES)*100);
	file_save ("result.txt",fbuf[3],res);

but in function don't cry


A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram
Re: pointers is my nightmare [Re: XD1v0] #268680
05/30/09 16:37
05/30/09 16:37
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
i dont get what exactly your problen is but it's probably this:
ok, it's not that.

Last edited by Quadraxas; 05/30/09 16:42.

3333333333
Re: pointers is my nightmare [Re: Quad] #268683
05/30/09 16:45
05/30/09 16:45
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
okay this is how you should do it:
Code:
typedef struct {short f[3];} MFACES;
MFACES* fbuf[100];

long create_stuct_array (MFACES** arr,var num)
{
	*arr = malloc (sizeof(MFACES)*num);memset(*arr,16,sizeof(MFACES)*num);
	return (sizeof(MFACES)*num);
}

void main ()
{
 long res = create_stuct_array (&fbuf[3],100);
 file_save ("result.txt",fbuf[3],res);	
}



3333333333
Re: pointers is my nightmare [Re: Quad] #268686
05/30/09 17:05
05/30/09 17:05
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline OP
Member
XD1v0  Offline OP
Member

Joined: Jun 2008
Posts: 151
Ukraine
WOW! its realy works, maybe i must learn more about pointers in c++ doc, thx Quadraxas


A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1