Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
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
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
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 Offline OP
User
Sphin  Offline 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 Offline
Senior Member
boatman  Offline
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.

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 Offline
Serious User
Ch40zzC0d3r  Offline
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 Offline
Junior Member
Finstratech  Offline
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 Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Ah okay, many thanks!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1