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
4 registered members (TipmyPip, AndrewAMD, dBc, clonman), 18,621 guests, and 5 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
Copying strings to character array #456884
12/14/15 17:21
12/14/15 17:21
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
When I run the following code it returns "pointer expected" error.
function main(){
static char a[2][500];
strcpy(a[0],"string");
strcpy(a[1],"string1");
printf("%s %s",a[0],a[1]);
}

Anyway to copy strings to a 2 dimension character array so that I can later retrieve them by referencing the first dimension of that array?

Re: Copying strings to character array [Re: trader6363] #456899
12/15/15 09:17
12/15/15 09:17
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
No, but you can either define a struct containing your 500 chars array, or simply:

char a[1000];
strcpy(a+0*500,"string0");
strcpy(a+1*500,"string1");


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1