Showing posts with label strcpy C program. Show all posts
Showing posts with label strcpy C program. Show all posts

Tuesday, September 29, 2020

, ,

How To Write strcpy Program In C / strcpy function in c

 strcpy function in c programming use to copy a sting from one variable to another variable. This article will help you to teach how to write the strcpy program in c programming.

 

How to Write strcpy Program In C
How to Write strcpy Program In C

strcpy is an library function in c so you have to define <string.h> Library in header of c program and this function return copied value.

Syntax:-

char *strcpy(char *val1, const char *val2);

strcpy program in c programming

#include <stdio.h>
#include <string.h> //string library 

int main() {
   char val1[20] = "strcpy C program";
   char val2[20];

   // copying str1 to str2
   strcpy(val2, val1);

   puts(str2); // Output(strcpy C program)

   return 0;
}


strcpy function can be used with ANSI/ISO 9899-1990 version.