C strcpy( ) function

  • By using this predefined function we can copy a string to another string.
  • strcpy() required two arguments of type char* i.e. an address of a string.
  • Syntax:

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

  • When we are working strcpy() function then from given source address upto null entire entire content will copy string.

Example:

#include
#include
#include
int main()
{
char s1[10]=”K2schools”;
char s2[10]=”Welcome”;
puts(s1);
puts(s2);
strcpy(s1,s2);
puts(s1);
puts(s2);
getch();
return 0;
}

Powered by k2schools