On this page
  1. strcpy
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

strcpy

Prev: strdup | Up: string.h | Next: strcat
Rel: snprintf(), string.h, stdlib.h & string.h Guide
Ref: cppreference — strcpy
Tags: #public #prog #c #stdlib #string #tier/legacy


Include

#include <string.h>

Signature & Overview

char *strcpy(char *restrict dst, const char *restrict src);

Unbounded string copy with no destination size check.

Legacy / Avoid: Prefer snprintf() in all new code.

Notes & Pitfalls

Example

#include <assert.h>
#include <stdio.h>
#include <string.h>

int main(void) {
    char dst[16];
    snprintf(dst, sizeof(dst), "%s", "safe copy");
    assert(strcmp(dst, "safe copy") == 0);
}

Linked from

Related notes