Register
Log In
Forums
Starting with Zorro
Simple C problem - array defined by a constant/variable
Forums
Calendar
Active Threads
Search
Forum Help
Gamestudio Links
► Features
► Download
► Online Manual
► Online Tutorial
► Free Resources
► F.A.Q.
Zorro Links
► Download
► Online Manual
► Online Tutorial
► Blog
► Support
► What's New?
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
multiple results graph in multi-asset scripts?
by Enivant. 04/14/23 10:16
Big Impact Sound | Experienced Composer looking for projects
by bigimpactsound. 04/13/23 20:07
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
Using Zorro to trade Indian equities using Broker APIs
by AndrewAMD. 04/11/23 14:19
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
Who's Online Now
3 registered members (
AndrewAMD
,
The_Judge
,
Grant
), 898 guests, and 5 spiders.
Key:
Admin
,
Global Mod
,
Mod
Newest Members
rki
,
FranzIII
,
indonesiae
,
The_Judge
,
storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple C problem - array defined by a constant/variable
#462889
11/02/16
22:57
11/02/16
22:57
Joined:
Dec 2013
Posts: 568
Fuerth, DE
Sphin
OP
User
Sphin
OP
User
Joined:
Dec 2013
Posts: 568
Fuerth, DE
int a = 2;
var b[a];
or
const int a = 2;
var b[a];
= Syntax Error.
Shouldn't at least the second way work, is it not possible to set the dimension of an array by a constant/variable?
Thanks, Sphin
Re: Simple C problem - array defined by a constant/variable
[
Re: Sphin
]
#462890
11/03/16
05:35
11/03/16
05:35
Joined:
Apr 2014
Posts: 482
Sydney, Australia
B
boatman
Senior Member
boatman
Senior Member
B
Joined:
Apr 2014
Posts: 482
Sydney, Australia
To create dynamic arrays, you need to allocate a contiguous memory area. The malloc() function should get you out of trouble I think.
www.robotwealth.com
Re: Simple C problem - array defined by a constant/variable
[
Re: boatman
]
#462893
11/03/16
11:36
11/03/16
11:36
Joined:
Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r
Serious User
Ch40zzC0d3r
Serious User
C
Joined:
Oct 2011
Posts: 1,082
Germany
GCC actually can create dynamic arrays on the stack, but thats not supported by most of the compilers.
You should use malloc as suggested.
Re: Simple C problem - array defined by a constant/variable
[
Re: Ch40zzC0d3r
]
#462895
11/03/16
15:51
11/03/16
15:51
Joined:
Feb 2014
Posts: 73
Montreal, Qc Canada
F
Finstratech
Junior Member
Finstratech
Junior Member
F
Joined:
Feb 2014
Posts: 73
Montreal, Qc Canada
What application could allocating memory have for automated trading?
Re: Simple C problem - array defined by a constant/variable
[
Re: Finstratech
]
#462904
11/04/16
00:19
11/04/16
00:19
Joined:
Dec 2013
Posts: 568
Fuerth, DE
Sphin
OP
User
Sphin
OP
User
Joined:
Dec 2013
Posts: 568
Fuerth, DE
Ah okay, many thanks!
Moderated by
Petra
Hop To
Gamestudio ------
Starting with Gamestudio
Atari lite-C
Editors & Templates
A8 Engine
Shaders
Third Party Tools
Acknex Users Magazine
The Past
The Future
Zorro ------
Starting with Zorro
Educational
Automated Trading
Zorro Scripts
The Z Systems
Zorro and the Brokers
Zorro Future
Feedback ------
Bug Hunt
Blame the Manual
Ask the Developers
Updates & Announcements
Rants
Game Creation ------
Game Design & Business
Jobs Wanted
Jobs Offered
User Resources
Projects
Showcase
Beyond Games & Money ------
Hilbert's Hotel
Morbius' Virtual Answering Machine
Print Thread
Switch to Threaded Mode
5
Excellent
4
Good
3
Average
2
Bad
1
Terrible
View Profile
Send Private Message
Follow User
Show Forum Posts
View Profile
Send Private Message
View Homepage
Follow User
Show Forum Posts
View Profile
Send Private Message
Follow User
Show Forum Posts
View Profile
Send Private Message
Follow User
Show Forum Posts
View Profile
Send Private Message
Follow User
Show Forum Posts
Default Style
gamestudio
UBBT77
UBBT77 - Dark2
Forum Rules
·
Mark All Read
·
Powered by UBB.threads™ PHP Forum Software 7.7.1