Struct

Postby md_lasalle on Sun Jan 12, 2003 6:00 pm

Does pocketc Supports Struct instruction? if yes what is the syntaxe?

thanks
md_lasalle
 
Posts: 74
Joined: Fri Dec 20, 2002 12:26 am
Location: Canada

Postby soinsg on Sun Jan 12, 2003 6:19 pm

No, but you can fake them:
Code: Select all
int player[2];
#define .x [0]
#define .y [1]

player.x = 10;

or:
Code: Select all
pointer player;
#define .x [0]
#define .y [1]
#define .name [2]

player = malloct(1, "iis"); //int int string
if (!player) alert("Bad malloct()!");
player.name = "mixed types";
soinsg
 
Posts: 198
Joined: Thu May 17, 2001 4:26 pm

Postby md_lasalle on Sun Jan 12, 2003 6:30 pm

I tried :

pointer Hero;
Hero = malloct(1,"isiisssssss");

and it says : "initializer doesn't match variable type"
md_lasalle
 
Posts: 74
Joined: Fri Dec 20, 2002 12:26 am
Location: Canada

Postby soinsg on Sun Jan 12, 2003 7:45 pm

Sorry, my bad, I should have said, "use malloct() inside another function".
Code: Select all
main() {
pointer ptr;
ptr = malloct(1, "scip");

//code here

free(ptr);
}
soinsg
 
Posts: 198
Joined: Thu May 17, 2001 4:26 pm


Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 4 guests

cron