copies string source to string target, pointer based 2 - C String

C examples for String:String Function

Description

copies string source to string target, pointer based 2

void strcpy(char *target, char *source)
{
  while(*target++ = *source++)
     ;                                               /* null statement */
}

Demo Code

/* Count spaces */
#include <stdio.h>

void strcpy(char *target, char *source)
{
   while (*target++ = *source++)
      ;                                               /* null statement */
}

int main(void)
{
   char *str = "this is a  test";
   char s[80];/*  w  w  w  . j  av a 2 s . co m*/

   strcpy(s, str);

   puts(s);

   return 0;
}

Result


Related Tutorials