Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 03/20/26 07:00
Black Book, 4th edition
by jcl. 03/17/26 09:28
Trying to get started...
by Lukudo. 03/16/26 09:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 4,918 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
mredit, vestriaa, Lukudo, mldenoiser, the1
19204 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: 28,089
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,089
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