Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Edgar_Herrera), 1,111 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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