Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
struct members #224986
09/02/08 12:52
09/02/08 12:52
Joined: Aug 2008
Posts: 25
B
bluemax Offline OP
Newbie
bluemax  Offline OP
Newbie
B

Joined: Aug 2008
Posts: 25
I'm trying to get a struct member string value and compare it to another string:
if(struct.member == "same_text")

I have also tried strcpy() and strcmp() but LC will not compile due to pointer errors.

any thought?

Re: struct members [Re: bluemax] #224990
09/02/08 13:14
09/02/08 13:14
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
check struct.member for being empty first
Code:
if(struct.member!=NULL)   //make sure not un-initialised
{  // do other checks here
   if(str_cmp(struct.member,"same_text")==0)
   {
      // they are the same - so do something
   }
}

and first usage of struct member MUST be a
Code:
struct.member = str_create("something");  //is now now initialised
I also assume you are using str_cpy() and str_cmp() and not strcpy() and strcmp()
because they ARE different...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: struct members [Re: EvilSOB] #225295
09/03/08 21:18
09/03/08 21:18
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Quote:
if(struct.member!=NULL) //make sure not un-initialised
Even that wont work when the structure is uninitialised. Although it doesn't generate a crash, it is not functioning properly either. Uninitialised members are not NULL, they are literally nothing. Thus the statement will be true. struct.member=NULL; is required for the statement to be false.

You always have to init every member at creation of the structure, that's the safest.


Click and join the 3dgs irc community!
Room: #3dgs
Re: struct members [Re: Joozey] #225329
09/04/08 02:35
09/04/08 02:35
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Thanks Joozey, you are right of course.

That is a hole I always fall into, call it a mental blank spot.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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

Gamestudio download | 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