Header File
string.h
Category
Memory and String Manipulation Routines, Inline Routines
Prototype
char *strnset(char *s, int ch, size_t n);
wchar_t *_wcsnset(wchar_t *s, wchar_t ch, size_t n);
unsigned char *_mbsnset(unsigned char *s, unsigned int ch, size_t n);
Description
Sets a specified number of characters in a string to a given character.
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
Each of these functions return 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; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
strnset |
|
+ |
|
|
_mbsnset |
|
+ |
|
|
_wcsnset |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|