Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualAnubiss

Posted 11 January 2012 - 02:45 AM

this malloc function sounds very good, but it seems like i need to understand a bit more about this and also pointers.
So i made now a struct for the stations i want to buy:

typedef struct{
int id;
int x;
int y;
int flag;
int entfx;
int entfy;
}ownstation;
ownstation neu[10];

Is it correct to make an array now if i for example don´t want to have more than 10 stations?

then i have found following for this malloc:

char * String;
String = (char *) malloc(1000);

so if the code would be:

if (klicking on "buy"){
do what?
}

EDIT:
ownstation* neu(neu[10](int id[10]));

something like this maybe? (i know that it is not correct, but maybe i am on the right way)

#2Anubiss

Posted 11 January 2012 - 02:45 AM

this malloc function sounds very good, but it seems like i need to understand a bit more about this and also pointers.
So i made now a struct for the stations i want to buy:

typedef struct{
int id;
int x;
int y;
int flag;
int entfx;
int entfy;
}ownstation;
ownstation neu[10];

Is it correct to make an array now if i for example don´t want to have more than 10 stations?

then i have found following for this malloc:

char * String;
String = (char *) malloc(1000);

so if the code would be:

if (klicking on "buy"){
do what?
}

EDIT:
ownstation* neu(neu[10](int id[10]));

something like this maybe? (i know that it is not correct, but maybe i am on the right way)

#1Anubiss

Posted 11 January 2012 - 02:29 AM

this malloc function sounds very good, but it seems like i need to understand a bit more about this and also pointers.
So i made now a struct for the stations i want to buy:

typedef struct{
int id;
int x;
int y;
int flag;
int entfx;
int entfy;
}ownstation;
ownstation neu[10];

Is it correct to make an array now if i for example don´t want to have more than 10 stations?

then i have found following for this malloc:

char * String;
String = (char *) malloc(1000);

so if the code would be:

if (klicking on "buy"){
do what?
}

PARTNERS