Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
acesing to linking structures #113447
02/23/07 11:08
02/23/07 11:08
Joined: Sep 2003
Posts: 407
inside to my
er_willy Offline OP
Senior Member
er_willy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 407
inside to my
//basic weapons data
typedef struct
{
char WEAPON_name;
int WEAPON_weigh;
int WEAPON_size;

}WEAPONS;

//fire weapons
typedef struct
{
WEAPONS weapons_str ;
int WEAPON_munition;
int WEAPON_range;

}FIRE_WEAPONS;

FIRE_WEAPONS OBJ_pistol = { WEAPON_munition = 8; WEAPON_range = 800;}


all correct for lite-c, but I not can use the data of the firs structure using the OBJ_pistol.

lite-c give error

example:

OBJ_pistol.weapons_str.WEAPON_weigh = 10;



Last edited by er_willy; 02/23/07 13:08.
Re: acesing to linking structures [Re: er_willy] #113448
02/23/07 15:56
02/23/07 15:56
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
There are two mistakes:

char WEAPON_name; => I suppose you mean char WEAPON_name[..];

FIRE_WEAPONS OBJ_pistol = {..} => FIRE_WEAPONS* OBJ_pistol = {..}

You can create initialized struct pointers, but not initialized structs.

Re: acesing to linking structures *DELETED* [Re: jcl] #113449
02/27/07 17:25
02/27/07 17:25
Joined: Sep 2003
Posts: 407
inside to my
er_willy Offline OP
Senior Member
er_willy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 407
inside to my
Post deleted by er_willy

Re: acesing to linking structures [Re: er_willy] #113450
02/27/07 17:57
02/27/07 17:57
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
You are using the C-script way of initializing strings. Better use str_create()
What you are doing is you create 30 string POINTERS, but they all point to nowhere.

Re: acesing to linking structures [Re: FBL] #113451
02/28/07 11:31
02/28/07 11:31
Joined: Sep 2003
Posts: 407
inside to my
er_willy Offline OP
Senior Member
er_willy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 407
inside to my
damed damed is again a typo, so sorry , and thanks Firoball

I have litte time, the code what put no is for any game, is a test over test, only for learn the new lite-c. And my englis is short for large questions.


ok I bening again, when fast code, and only the original question of the post:


//If you create a linking strutures, in this example the struc_01 is linking inside of struc_02...

typedef struct
{
var var_struct01;

}struct01;

typedef struct
{
struct01 struct_01;
var var_struct02;

}struct02;

//...if you wanna create initialized struct pointers with linking structures. what is the code??...

//This not give error when compiler, but not work var_struct01 contain 0.
struct02* struct_test ={var_struct01 = 1; var_struct02 = 2;}


//this give error
struct02* struct_test ={{var_struct01 = 1;} var_struct02 = 2;}


struct02* struct_test ={{var_struct01 = 1;}; var_struct02 = 2;}

Re: acesing to linking structures [Re: er_willy] #113452
02/28/07 17:37
02/28/07 17:37
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
struct02 test;

test.var_struct02 = 2;
test.struct_01.var_struct01 = 1;

Re: acesing to linking structures [Re: FBL] #113453
02/28/07 18:11
02/28/07 18:11
Joined: Sep 2003
Posts: 407
inside to my
er_willy Offline OP
Senior Member
er_willy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 407
inside to my
yes, thaks for you time. and yes is the best workaround, and I know what this work.

but is posible in the line

struct02* struct_test = ...


@Firoball
I can give to you the adress of my house, if you wanna going to hammer my head.

Re: acesing to linking structures [Re: FBL] #113454
02/28/07 18:26
02/28/07 18:26
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
struct02* test;

test = (struct02*)malloc(sizeof(struct02));
test->var_struct02 = 2;
test->struct_01.var_struct01 = 1;

Re: acesing to linking structures [Re: FBL] #113455
03/02/07 10:06
03/02/07 10:06
Joined: Sep 2003
Posts: 407
inside to my
er_willy Offline OP
Senior Member
er_willy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 407
inside to my
ok, many thaks.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1