The stchar() function
The stchar() function stores a null-terminated string in a fixed-length string, padding the end with blanks, if necessary.
Syntax
void stchar(from, to, count)
char *from;
char *to;
mint count;
- from
- A pointer to the first byte of a null-terminated source string.
- to
- A pointer to the fixed-length destination string. This argument can point to a location that overlaps the location to which the from argument points. In this case, Informix® ESQL/C discards the value to which from points.
- count
- The number of bytes in the fixed-length destination string.
Example
This sample program is in the stchar.ec file
in the demo directory.
/*
* stchar.ec *
The following program shows the blank padded result produced by
stchar() function.
*/
#include <stdio.h>
main()
{
static char src[] = "start";
static char dst[25] = "123abcdefghijkl;.";
printf("STCHAR Sample ESQL Program running.\n\n");
printf("Source string: [%s]\n", src);
printf("Destination string before stchar: [%s]\n", dst);
stchar(src, dst, sizeof(dst) - 1);
printf("Destination string after stchar: [%s]\n", dst);
printf("\nSTCHAR Sample Program over.\n\n");
}
Output
STCHAR Sample ESQL Program running.
Source string: [start]
Destination string before stchar: [123abcdefghijkl;.]
Destination string after stchar: [start ]
STCHAR Sample Program over.