Copyright © tutorialspoint.com

C - strcpy function

previous

Synopsis:

#include <stdio.h>

char *strcpy (char *dest, char *src); 

Description:

The strcpy function copies characters from src to dest up to and including the terminating null character.

Return Value

The strcpy function returns dest.

Example

#include <stdio.h>

int main() {
  char input_str[20];
  char *output_str;

  strcpy(input_str, "Hello");
  printf("input_str: %s\n", input_str);

  output_str = strcpy(input_str, "World");

  printf("input_str: %s\n", input_str);
  printf("output_str: %s\n", output_str);

  return 0;
}

It will proiduce following result:

input_str: Hello
input_str: World
output_str: World

previous

Copyright © tutorialspoint.com