The stleng() function
The stleng() function returns the length, in bytes, of a null-terminated string that you specify.
Syntax
mint stleng(string)
char *string;
- string
- A pointer to a null-terminated string.
Usage
The length does not include the null terminator.
Example
This sample program is in the stleng.ec file
in the demo directory.
/*
* stleng.ec *
This program uses stleng to find strings that are greater than 35
characters in length.
*/
#include <stdio.h>
char *strings[] =
{
"Your First Season's Baseball Glove",
"ProCycle Stem with Pearl Finish",
"Athletic Watch w/4-Lap Memory, Olympic model",
"High-Quality Kickboard",
"Team Logo Silicone Swim Cap - fits all head sizes",
};
main(argc, argv)
int argc;
char *argv[];
{
mint length, i;
printf("STLENG Sample ESQL Program running.\n\n");
printf("Strings with lengths greater than 35:\n");
i = 0;
while(strings[i])
{
if((length = stleng(strings[i])) > 35)
{
printf(" String[%d]: %s\n", i, strings[i]);
printf(" Length: %d\n\n", length);
}
++i;
}
printf("\nSTLENG Sample Program over.\n\n");
}
Output
STLENG Sample ESQL Program running.
Strings with lengths greater than 35:
String[2]: Athletic Watch w/4-Lap Memory, Olympic model
Length: 44
String[4]: Team Logo Silicone Swim Cap - fits all head sizes
Length: 49
STLENG Sample Program over.