The ldchar() function
The ldchar() function copies a fixed-length string into a null-terminated string and removes any trailing blanks.
Syntax
void ldchar(from, count, to)
char *from;
mint count;
char *to;
- from
- A pointer to the fixed-length source string.
- count
- The number of bytes in the fixed-length source string.
- to
- A pointer to the first byte of a null-terminated destination string. The to argument can point to the same location as the from argument, or to a location that overlaps the from argument. If so, ldchar() does not preserve the value to which from points.
Example
This sample program is in the ldchar.ec file
in the demo directory.
/*
* ldchar.ec *
The following program loads characters to specific locations in an array
that is initialized to z's. It displays the result of each ldchar()
operation.
*/
#include <stdio.h>
main()
{
static char src1[] = "abcd ";
static char src2[] = "abcd g ";
static char dest[40];
printf("LDCHAR Sample ESQL Program running.\n\n");
ldchar(src1, stleng(src1), dest);
printf("\tSource: [%s]\n\tDestination: [%s]\n\n", src1, dest);
ldchar(src2, stleng(src2), dest);
printf("\tSource: [%s]\n\tDestfination: [%s]\n", src2, dest);
printf("\nLDCHAR Sample Program over.\n\n");
}
Output
LDCHAR Sample ESQL Program running.
Source: [abcd ]
Destination: [abcd]
Source: [abcd g ]
Destination: [abcd g]
LDCHAR Sample Program over.