from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites:gentoo.linuxhowtos.org



Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

215223

userrating:


May 25th. 2007:
Words

486

Views

261787

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

154019

userrating:


April, 26th. 2006:

Druckversion
You are here: manpages





strcpy

Section: C Library Functions (3)
Updated: 202-0-03
Index Return to Main Contents
 

NAME

strcpy, strcat - string copy/catenate  

LIBRARY

Standard C library (libc,~-lc)  

SYNOPSIS

#include <string.h>
char *strcpy(char *restrict dst, const char *restrict src);
char *strcat(char *restrict dst, const char *restrict src);
 

DESCRIPTION

strcpy()
This function copies the string pointed to by src, into a string at the buffer pointed to by dst. The programmer is responsible for allocating a destination buffer large enough, that is, strlen(src) + 1.
It is equivalent to
stpcpy(dst, src), dst
strcat()
This function catenates the string pointed to by src, after the string pointed to by dst (overwriting its terminating null byte). The programmer is responsible for allocating a destination buffer large enough, that is, strlen(dst) + strlen(src) + 1.
It is equivalent to
stpcpy(strnul(dst), src), dst
 

RETURN VALUE

These functions return dst.  

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).
InterfaceAttributeValue
strcpy(), strcat() Thread safetyM-Safe
 

STANDARDS

C11, POSIX.-2008.  

HISTORY

POSIX.-2001, C89, SVr4, 4.3BSD.  

CAVEATS

The strings src and dst may not overlap. If the destination buffer is not large enough, the behavior is undefined. See _FORTIFY_SOURCE in feature_test_macros(7).  

EXAMPLES

#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) {
    char    *buf1;
    size_t  len, size;
    size = strlen("Hello ") + strlen("world") + strlen("!") + 1;
    buf1 = malloc(sizeof(*buf1) * size);
    if (buf1 == NULL)
        err(EXIT_FAILURE, "malloc()");
    strcpy(buf1, "Hello ");
    strcat(buf1, "world");
    strcat(buf1, "!");
    len = strlen(buf1);
    printf("[len = %zu]: ", len);
    puts(buf1);  // "Hello world!"
    free(buf1);
    exit(EXIT_SUCCESS); }  

SEE ALSO

stpcpy(3), strdup(3), string(3), wcscpy(3), string_copying(7)


 

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUE
ATTRIBUTES
STANDARDS
HISTORY
CAVEATS
EXAMPLES
SEE ALSO





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 15.5 ms