Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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