Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stpncpy(3) [suse man page]

STPNCPY(3)						     Linux Programmer's Manual							STPNCPY(3)

NAME
stpncpy - copy a fixed-size string, returning a pointer to its end SYNOPSIS
#define _GNU_SOURCE #include <string.h> char *stpncpy(char *dest, const char *src, size_t n); DESCRIPTION
The stpncpy() function copies at most n characters from the string pointed to by src, including the terminating '' character, to the array pointed to by dest. Exactly n characters are written at dest. If the length strlen(src) is smaller than n, the remaining characters in the array pointed to by dest are filled with '' characters. If the length strlen(src) is greater or equal to n, the string pointed to by dest will not be '' terminated. The strings may not overlap. The programmer must ensure that there is room for at least n characters at dest. RETURN VALUE
stpncpy() returns a pointer to the terminating null in dest, or, if dest is not null-terminated, dest + n. CONFORMING TO
This function is a GNU extension. SEE ALSO
strncpy(3), wcpncpy(3), feature_test_macros(7) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
1999-07-25 STPNCPY(3)

Check Out this Related Man Page

STPNCPY(3)                                                   Linux Programmer's Manual                                                  STPNCPY(3)

NAME
stpncpy - copy a fixed-size string, returning a pointer to its end SYNOPSIS
#include <string.h> char *stpncpy(char *dest, const char *src, size_t n); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): stpncpy(): Since glibc 2.10: _POSIX_C_SOURCE >= 200809L Before glibc 2.10: _GNU_SOURCE DESCRIPTION
The stpncpy() function copies at most n characters from the string pointed to by src, including the terminating null byte (''), to the array pointed to by dest. Exactly n characters are written at dest. If the length strlen(src) is smaller than n, the remaining characters in the array pointed to by dest are filled with null bytes (''), If the length strlen(src) is greater than or equal to n, the string pointed to by dest will not be null-terminated. The strings may not overlap. The programmer must ensure that there is room for at least n characters at dest. RETURN VALUE
stpncpy() returns a pointer to the terminating null byte in dest, or, if dest is not null-terminated, dest+n. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------+---------------+---------+ |Interface | Attribute | Value | +----------+---------------+---------+ |stpncpy() | Thread safety | MT-Safe | +----------+---------------+---------+ CONFORMING TO
This function was added to POSIX.1-2008. Before that, it was a GNU extension. It first appeared in version 1.07 of the GNU C library in 1993. SEE ALSO
strncpy(3), wcpncpy(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU 2016-03-15 STPNCPY(3)
Man Page

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

why is this code generating syntax error?pls help

#!/bin/sh copy() { source=`stat -c %s $1` dest=0 cd $2 while ;do cp $1 $2 & pct=`((100 * $dest) / $source )` dest=`dest+1` echo -en ".$pct%\b\b\b" sleep 1 done } echo "starting now" copy /file1 /tmp (3 Replies)
Discussion started by: wrapster
3 Replies

2. Shell Programming and Scripting

Need to take one part from a string

I have a string something like "/opt/src/default.cfg" OR /opt/src/common/one This whole string stored in an array. The problem is this string is not constant and it will keep on changing as lot of strings are stored in the array and it will be look like :- case 1 /opt/src/default.cfg ... (8 Replies)
Discussion started by: Renjesh
8 Replies

3. Shell Programming and Scripting

makefile sourc and dest are in different directory

Hi, in makefile, if the sourc and dest in different directory, no matter the source file changed or not, it seems the dest always been build, how do you resolve this? Thanks. peter (1 Reply)
Discussion started by: laopi
1 Replies

4. Shell Programming and Scripting

Remove characters from fixed length file

Hello I've question on the requirement I am working on. We are getting a fixed length file with "33" characters long. We are processing that file loading into DB. Now some times we are getting a file with "35" characters long. In this case I have to remove two characters (in 22,23... (14 Replies)
Discussion started by: manasvi24
14 Replies