Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TedMar, Ayumi), 1,374 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
variable as array argument #218341
07/28/08 07:13
07/28/08 07:13
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
I don't understand y this is not possible in lite-c. its giving me compile error.

int i = 200;

typedef struct
{
....
....
} structAgent;

structAgent xyz[i];

....
.....
......


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: variable as array argument [Re: delinkx] #218343
07/28/08 07:30
07/28/08 07:30
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Try i as constant if it fulfills your needs.

Re: variable as array argument [Re: PadMalcom] #218346
07/28/08 07:45
07/28/08 07:45
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
Originally Posted By: PadMalcom
Try i as constant if it fulfills your needs.


i want to change the i variable. so i cannot keep it as constant i guess. is there any way to do this ?


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: variable as array argument [Re: delinkx] #218530
07/29/08 07:08
07/29/08 07:08
Joined: Mar 2006
Posts: 15
Kansas, USA
Q
quantum69 Offline
Newbie
quantum69  Offline
Newbie
Q

Joined: Mar 2006
Posts: 15
Kansas, USA
Look up dynamically resizing array if that's what you're trying to do, which is the only reason I could see for wanting an index size value that changes. Standard C would balk at changing an array size like this as well, it's bad form since you could increase your array size and go out of bounds into whatever was allocated in memory after it. I know Lite-C handles resizing strings automatically if you use the Lite-C string functions, but try doing it from a DLL and it'll crash periodically because of the out-of-bounds issue.

Something like you're seeming to do generally requires reallocating a memory chunk of the appropriate size to hold your array of structs, copying the data into the new array elements then freeing the old array. You may be asking Lite-C to perform a task it's not designed to handle automatically.

This problem would best be handled by using a linked-list methodology. Look up linked-lists on the net and get a firm understanding of how they can cope with unlimited (well, memory constrained) numbers of arrayed structs just like this problem. Since you can do pointers in Lite-C I'd point you in that direction.

Unless someone else knows otherwise.

QM


Last edited by quantum69; 07/29/08 07:11.

------------------------------------
Quantum Mechanic
Better living at the subatomic level
Re: variable as array argument [Re: quantum69] #218534
07/29/08 07:19
07/29/08 07:19
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
i think malloc function of memory allocation will do this. right ? but can malloc be used in Lite-C ? i dont wanna use the DLL or C++.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: variable as array argument [Re: delinkx] #218548
07/29/08 07:59
07/29/08 07:59
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Yeah, malloc(), free(), etc are ported straight from C.
So you wont find much mention in the 3DGS helpfiles about them.
Use any old C, C++ documentation for usage.

They are included by the "LiteC.h" header or you can #include the "malloc.h" that comes bundled with A7.
Well, it was bundled with my A7 commercial version anyway. Dont know about Free Lite-C....



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: variable as array argument [Re: EvilSOB] #218556
07/29/08 08:39
07/29/08 08:39
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
Originally Posted By: EvilSOB
Yeah, malloc(), free(), etc are ported straight from C.
So you wont find much mention in the 3DGS helpfiles about them.
Use any old C, C++ documentation for usage.

They are included by the "LiteC.h" header or you can #include the "malloc.h" that comes bundled with A7.
Well, it was bundled with my A7 commercial version anyway. Dont know about Free Lite-C....


kool.. i know how to use the malloc function in C. so will not be a problem here. will check the include file. i have the educational version. so should be ok i guess. will check now. thnkx.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook

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