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

strcat

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


Include

#include <string.h>

Signature & Overview

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

Unbounded string concatenation with $O(n)$ repeated scanning.

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

Notes & Pitfalls

Example

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

int main(void) {
    char buf[16];
    snprintf(buf, sizeof(buf), "%s%s", "hello ", "c");
    assert(strcmp(buf, "hello c") == 0);
}

Linked from

Related notes