Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (SBGuy, Quad), 768 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Creating an array of strings #452977
07/02/15 16:11
07/02/15 16:11
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
Hi
I would like to create a 2d array that hold strings, however I cant figure out how to do this in lite-c. In c I can do something like this:
char a[2][10];
strcpy(a[0], "123456789");
strcpy(a[1], "hello");

Thanks

Re: Creating an array of strings [Re: trader6363] #452991
07/03/15 13:24
07/03/15 13:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Your array holds chars, not strings. Strings are char pointers.

For strings:

string a[2];
a[0] = "123456789";
a[1] = "hello";

For chars:

static char a[20];
strcpy(a,"123456789");
strcpy(a+10,"hello");

Re: Creating an array of strings [Re: jcl] #452996
07/03/15 16:16
07/03/15 16:16
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
Wow, I spent hours over complicating this and the answer is so simple. Thanks!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1