Borland C++ reference

strnset, _fstrnset

raw OCR

Sets a specified number of characters in a string to a given character.

Defined in header <string.h>

Syntax

#include <string.h>
Near  version: char *strnset(char   *s, int ch,sizet n);
Far version: char  far * far _fstrnset(char  far *s, int ch, sizet n)

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

strnset copies the character ch into the first n bytes of the string s . If n > strlen(s), then strlen(s) replaces n. It stops when n characters have been set, or when a null character is found.

Return value

strnset returns s.

Example

#include <stdio.h>
#include <string.h>

int main(void)
{
   char *string = "abcdefghijklmnopqrstuvwxyz";
   char letter = 'x';
   printf("string before strnset: %s\n", string);
   strnset(string, letter, 13);
   printf("string after  strnset: %s\n", string);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `strnset, fstrnset` read as `strnset, _fstrnset`