| String |
|
typedict |
| |
A
String
is an ordered collection of small non-negative integers that can
represent any 16 bit Unicode character.
Elements in a string can be accessed by numeric index using familiar
subscript or pointer notation:
string[0] *string string[i+j] *(string+i+j)
Uninitialized elements always start at
0,
which is also called the null character.
Yoix strings are not explicitly null terminated.
However, built-ins that work with strings and look like they came from
C
behave the way you would expect;
they simply assume there is a terminating null character if they get
to the end of a string before finding one.
| |
| Example: |
The program,
import yoix.stdio.*;
String s1[3];
String s2 = "hello, world";
String s3[10] = "xyzzy";
printf("s1=|%S|\ns2=|%S|\ns3=|%S|\n", s1, s2, s3);
creates three strings, initializes some of the elements, and then prints
s1=|\0\0\0|
s2=|hello, world|
s3=|xyzzy\0\0\0\0\0|
on standard output (where
\0
is used to represent otherwise invisible null characters).
Notice how we used the
%S
format to dump all the elements in each string,
including the null characters.
The
%O
format would also work, but we could not use
%s,
because it stops at the first null character.
| | |
| See Also: |
Array,
Dictionary,
Hashtable,
Vector
|
|
Yoix is a registered trademark of AT&T Inc.
|