1 registered members (AndrewAMD),
840
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
strings
#271885
06/15/09 15:10
06/15/09 15:10
|
Joined: Jan 2006
Posts: 33 California
Amanda_Dearheart
OP
Newbie
|
OP
Newbie
Joined: Jan 2006
Posts: 33
California
|
If I create a string such as
String *MyString = "Hi out there"
is there a way I can retrieve individual characters such as the letter H, and then the letter i, and then the letter o, etc. etc. etc.
Also does the string support concatenation, such as
Mystring = String1 + String2
thanks for any help!
Prepare to be assimilated. Resistance is futile
Amanda Dearheart
Business E-mail : cjw.roberson@gmail.com
|
|
|
Re: strings
[Re: MMike]
#271989
06/15/09 23:25
06/15/09 23:25
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! I used str_clip at one point. I transfered all the letters of the string to numbers put the numbers in an array and then I used: if the number is .... Ottawa
|
|
|
Re: strings
[Re: CharlieAmer]
#272321
06/17/09 13:24
06/17/09 13:24
|
Joined: Aug 2003
Posts: 902 Van Buren, Ar
Gordon
User
|
User
Joined: Aug 2003
Posts: 902
Van Buren, Ar
|
to access first letter u use strng[0], second letter strng[1] While this will work in C for a char array it will NOT work in lite-c. STRING is defined in atypes.h as
typedef struct STRING {
C_LINK link;
char *chars; // pointer to null terminated string
long length; // allocated length of string
long flags; // see STRF_... above
byte pad[PAD_STRING];
} STRING;
Therefore you must access the character data as (strname.chars)[index]. The first character is index = 0 etc. Just remember that STRING* is not the same as char*.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|