I have a simulation program that I want to port from matlab to C. But my C has gone rusty..
I have a system (in the mathematical sense) which, at each iteration, gets in a new state. In order to determine this new state, I have to determine first what is theoretically possible, and choose among these possibilities. When the simulation starts, I have but a few possible outcomes. As the simulation progresses, the number of possible outcomes increases. From a mere dozen to several hundred thousand possibilities.. So I try to deal with these outcomes in a dynamical way.
I am trying to get all this done in a function that will return the event that took place. I define
Expand|Select|Wrap|Line Numbers
- typedef struct{
- CITY FromCity;
- CITY ToCity;
- int TypeEvent;
- double ProbaEvent;
- double Time;
- } EVENT;
Expand|Select|Wrap|Line Numbers
- EVENT *possible_events;
Expand|Select|Wrap|Line Numbers
- possible_events=(EVENT *) realloc(possible_events,(nb_event+1)*sizeof(EVENT));
- if (possible_events == NULL)
- {
- printf("Problem reallocating possible_events\n");
- exit(1);
- }
- possible_events[nb_event]->FromCity=i;
stochastic_simulation.c: In function ‘Determine_Event’:
stochastic_simulation.c:306: error: invalid type argument of ‘->’
Can anyone remind me what it is that I should/should not be doing..? Thanks.
(I should add that, being in doubt, I tried the dot dereferencing instead of the ->, and was sent packing with a different love message from gcc, something about incompatible types I believe).