The byleng() function

The byleng() function returns the number of significant characters in a string, not counting trailing blanks.

Syntax

mint byleng(from, count)
   char *from;
   mint count;
from
A pointer to a fixed-length string (not null-terminated).
count
The number of bytes in the fixed-length string. This does not include trailing blanks.

Example

This sample program is in the byleng.ec file in the demo directory.
/*
   * byleng.ec *

   The following program uses byleng() to count the significant characters 
   in an area.
*/

#include <stdio.h>

main()
{
    mint x;
    static char area[20] = "xxxxxxxxxx         ";


    printf("BYLENG Sample Program running.\n\n");

            /* initial length */
    printf("Initial string:\n");
    x = byleng(area, 15);            
    printf("  Length =  %d, String = '%s'\n", x, area);

            /* after copy */
    printf("\nAfter copying two 's' characters starting ");
    printf("at position 16:\n");
    bycopy("ss", &area[16], 2);
    x = byleng(area, 19);
    printf("  Length = %d, String = '%s'\n", x, area);

    printf("\nBYLENG Sample Program over.\n\n");
}

Output

BYLENG Sample Program running.

Initial string:
  Length = 10, String = 'xxxxxxxxxx         '

After copying two 's' characters starting at position 16:
  Length = 18, String =  'xxxxxxxxxx      ss '

BYLENG Sample Program over.