Raised This Month: $ Target: $400
 0% 

How can I create an array of strings?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nvkkk
Junior Member
Join Date: Mar 2011
Old 04-02-2011 , 12:24   How can I create an array of strings?
Reply With Quote #1

So that myArr[0] is a 32char string, myArr[1] another...
Is this the correct way?
new String:myArr[64][64] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
nvkkk is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 04-02-2011 , 13:16   Re: How can I create an array of strings?
Reply With Quote #2

Yup, that's the correct way, but by using new, it blanks out all the values so you don't need to set them:

PHP Code:
new String:myArr[64][40];

// If you wanted define some values
new String:myArr[][] =
{
     
"first string",
     
"second string"
}; 
This creates 64 strings, each with a 40 character limit. To read one of them, we would do:
PHP Code:
PrintToServer("The value is: %s"myArr[0]); 
__________________

Last edited by pheadxdll; 04-02-2011 at 13:18.
pheadxdll is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode