strncpy


strncpy

Copies the first n characters of a string to another location

 #include <string.h> char *strncpy ( char * restrict dest , const char * restrict src , size_t n  ); 

The strncpy( ) function copies at most n characters from the string addressed by src to the char array addressed by dest, which must be large enough to accommodate n characters. The strncpy( ) function returns the value of its first argument, dest. The locations that strncpy( ) reads from and writes to using its restricted pointer parameters must not overlap.

If there is no terminating null character within the first n characters of src, then the copied string fragment is not terminated.


If strncpy( ) reads a null character from src before it has copied n characters, then the function writes null characters to dest until it has written a total of n characters.

Example

See the examples for strcspn( ) and strpbrk( ) in this chapter.

See Also

strcpy( ), memcpy( ), memmove( ), wcsncpy( ), wmemcpy( ), wmemmove( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net