logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

strncpy.3p (3348B)


  1. '\" et
  2. .TH STRNCPY "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. stpncpy, strncpy
  12. \(em copy fixed length string, returning a pointer to the array end
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <string.h>
  17. .P
  18. char *stpncpy(char *restrict \fIs1\fP, const char *restrict \fIs2\fP, size_t \fIn\fP);
  19. char *strncpy(char *restrict \fIs1\fP, const char *restrict \fIs2\fP, size_t \fIn\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. For
  23. \fIstrncpy\fR():
  24. The functionality described on this reference page is aligned with the
  25. ISO\ C standard. Any conflict between the requirements described here and the
  26. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  27. .P
  28. The
  29. \fIstpncpy\fR()
  30. and
  31. \fIstrncpy\fR()
  32. functions shall copy not more than
  33. .IR n
  34. bytes (bytes that follow a NUL character are not copied) from the array
  35. pointed to by
  36. .IR s2
  37. to the array pointed to by
  38. .IR s1 .
  39. .P
  40. If the array pointed to by
  41. .IR s2
  42. is a string that is shorter than
  43. .IR n
  44. bytes, NUL characters shall be appended to the copy in the array
  45. pointed to by
  46. .IR s1 ,
  47. until
  48. .IR n
  49. bytes in all are written.
  50. .P
  51. If copying takes place between objects that overlap, the behavior is
  52. undefined.
  53. .SH "RETURN VALUE"
  54. If a NUL character is written to the destination, the
  55. \fIstpncpy\fR()
  56. function shall return the address of the first such NUL character.
  57. Otherwise, it shall return
  58. .IR &s1 [ n ].
  59. .P
  60. The
  61. \fIstrncpy\fR()
  62. function shall return
  63. .IR s1 .
  64. .P
  65. No return values are reserved to indicate an error.
  66. .SH ERRORS
  67. No errors are defined.
  68. .LP
  69. .IR "The following sections are informative."
  70. .SH EXAMPLES
  71. None.
  72. .SH "APPLICATION USAGE"
  73. Applications must provide the space in
  74. .IR s1
  75. for the
  76. .IR n
  77. bytes to be transferred, as well as ensure that the
  78. .IR s2
  79. and
  80. .IR s1
  81. arrays do not overlap.
  82. .P
  83. Character movement is performed differently in different
  84. implementations. Thus, overlapping moves may yield surprises.
  85. .P
  86. If there is no NUL character byte in the first
  87. .IR n
  88. bytes of the array pointed to by
  89. .IR s2 ,
  90. the result is not null-terminated.
  91. .SH RATIONALE
  92. None.
  93. .SH "FUTURE DIRECTIONS"
  94. None.
  95. .SH "SEE ALSO"
  96. .IR "\fIstrcpy\fR\^(\|)",
  97. .IR "\fIwcsncpy\fR\^(\|)"
  98. .P
  99. The Base Definitions volume of POSIX.1\(hy2017,
  100. .IR "\fB<string.h>\fP"
  101. .\"
  102. .SH COPYRIGHT
  103. Portions of this text are reprinted and reproduced in electronic form
  104. from IEEE Std 1003.1-2017, Standard for Information Technology
  105. -- Portable Operating System Interface (POSIX), The Open Group Base
  106. Specifications Issue 7, 2018 Edition,
  107. Copyright (C) 2018 by the Institute of
  108. Electrical and Electronics Engineers, Inc and The Open Group.
  109. In the event of any discrepancy between this version and the original IEEE and
  110. The Open Group Standard, the original IEEE and The Open Group Standard
  111. is the referee document. The original Standard can be obtained online at
  112. http://www.opengroup.org/unix/online.html .
  113. .PP
  114. Any typographical or formatting errors that appear
  115. in this page are most likely
  116. to have been introduced during the conversion of the source files to
  117. man page format. To report such errors, see
  118. https://www.kernel.org/doc/man-pages/reporting_bugs.html .