strcpy() function in C is used to copy the contents from one string (source) to another string (destination).
The strcpy() function is defined in the header file string.h
. It takes two arguments, destination and source. The source is from where the string is taken and the destination is to where the string is copied and written as follows:
strcpy(destination, source);
C Program for strcpy() function
| #include <stdio.h> #include <string.h> int main() { char str1[20] = "Simple2Code"; char str2[20]; printf("String on str2: %s.", strcpy(str2, str1)); return 0; } |
Output:
String on str2: Simple2Code.
In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read MoreIn this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read MoreIn this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read MoreIn this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read MoreIn this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read MoreIn this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in …
Read More