I am very confused at how I should declare structs and typedefs in Sieve I am reading - and according to the answer, what I am doing should be right. I'm trying to declare a simple type (currently only a vector), and used it with pointers, but something is very wrong, and I'm getting the error (includes other compiler output including command) : My code is as follows: I can not work for my life which is wrong I think I have done everything right, but the error seems to me that I have done something wrong in declaring this way, or possibly the way I have declared the array. A little bit Edit it : I'm tired, and probably will not understand much - basically I would like to be able to make an agent similar to "objects", C ++ objects, and be able to manipulate them simply I know that I just I can use ++, but I am trying to learn more about C, and therefore I think I'm cheating on something. or equivalent i. E. The address of the GCC main CE simulator - LM-WAL -STD = CMTM main C: in function: main ????: main.c: 20: 3: error: incompatible logic Type 1 for ???? Init_agentate Init_agent (agent_list [i]); ^ Main.c: 9: 6: Note: Expected 'Strategic Agent Agent' but a kind of argument? Agent ?? Zero init_agent (Agent * A) ^ make: *** [Main] Error 1 [Finished in 0.0s with clearance code] 2
#include & lt; Stdlib.h & gt; Typefif Structure Agent_s {Float X; Float Y; } Agent; Zero init_agent (agent * a) {a-> X = (float) (rand ()% 100) / 10; A-> Y = (float) (rand (%) 100/10;} int main (int argc, char ** argv) {int agent_count = 10; agent * agent_list = malloc (agent) * agent count; I = 0; i & lt; agent_ count; i ++) init_agent (agent_list [i]); return 0;}
[] membership operator dereferences no Etk Instead you should
init_agent (& agent_list [i]);
init_agent (agent_list + i);
i th item in the list, and not yourself.
No comments:
Post a Comment