Copy string: how to use strcpy : String Copy « String « C / ANSI-C






Copy string: how to use strcpy



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

int main ()
{
  char str1[]="Sample";
  char str2[40];
  char str3[40];

  strcpy (str2, str1);
  strcpy (str3, "copy");

  printf ("str1= %s\n str2= %s\n str3= %s\n", str1, str2, str3);
  return 0;
}

           
       








Related examples in the same category

1.how to use strcpy (string copy)
2.A simple string copy
3. Copy characters from one string to another: how to use strncpy
4.String copy: assign the pointer value
5.Copy a string