Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,541 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Access a string of a struct #149818
08/23/07 12:13
08/23/07 12:13
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline OP
Member
dennis  Offline OP
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
Hi!

I want to store data in a string of a struct.

There's an error:
"Crash in main"

code:
Code:
 #include <acknex.h>
#include <default.c>


typedef struct
{

STRING* Name;


} TEST;

TEST* Test;

function main()
{

wait(1);

str_cpy(Test.Name,"hhh");

}



How can I access the string?

Re: Access a string of a struct [Re: dennis] #149819
08/23/07 17:40
08/23/07 17:40
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You forgot to assign a value to Test. Test is just a pointer and not a struct. Add the folowing line after the wait(1) in your main function:

Test = malloc(sizeof(TEST));


Always learn from history, to be sure you make the same mistakes again...
Re: Access a string of a struct [Re: Uhrwerk] #149820
08/23/07 17:47
08/23/07 17:47
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Also you only have a STRING* pointer. you need to use str_create...

function main()
{
TEST teststruct;
Test = &teststruct;// if you really want to use a pointer for some reason - you can also do as suggested by Uhrwerk
wait(1);

Test.Name = str_create("hhh");
}

Re: Access a string of a struct [Re: FBL] #149821
08/23/07 19:20
08/23/07 19:20
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline OP
Member
dennis  Offline OP
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
Yes, that's it!

Thanks, Uhrwerk and Firoball......it's working now...!


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