October 01, 1999
The Small Scripting Language
(a)
bool: ispacked(string[])
return bool: (string[0] > charmax);
(b)
strlen(string[])
{
new len = 0;
if (ispacked(string))
while (string{len} ! '^0') /* get character from pack */
++len;
else
while (string[len] ! = '^0') /* get cell */
++len;
return len;
}
Example 2: (a) Function that distinguishes packed from unpacked strings; (b) the strlen() function that works on packed and unpacked strings.
Copyright © 1999, Dr. Dobb's Journal
|
|
||||||||||||||||||||||||||||
|
|
|
|