Algorithm


Code Examples

#1 Code Example with C Programming

Code - C Programming

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

int main ()
{
  char string1[]="First String"; 
  char string2[50];
  char string3[50];
  
  strcpy (string2, string1); // copy string1 to string2 variable
  strcpy (string3, "Another String"); // copy "Another String" to string3 variable
  
  printf ("String 1: %s\nString 2: %s\nString 3: %s\n", string1, string2, string3);
  return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
String 1: First String
String 2: First String
String 3: Another String
Advertisements

Demonstration


Copy String C Programming Example

https://www.cplusplus.com/reference/cstring/strcpy/

 

Next
Appending into a File in C Programming