Doubt about strcopy

1

I would like to know what the real feature of strcopy is from the string.h library and what does this C method do, I think what is in a set of characters is copied into a pointer from another set of characters. But I would like to know exactly what it does and if it copies all the memory addresses up to \ 0, or all without taking into account \ 0

    
asked by RoyalUp 28.04.2016 в 10:55
source

1 answer

2

The strcopy copies a string to another pointer. You copy the entire string and the string ends with the \ 0 included. On the destination pointer begins to put the string of the origin, you have the content in duplicate pointed each by its pointer.

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

int main()
{
   char src[40];
   char dest[100];

   memset(dest, '
#include <stdio.h>
#include <string.h>

int main()
{
   char src[40];
   char dest[100];

   memset(dest, '%pre%', sizeof(dest));
   strcpy(src, "Hola buenos días");
   strcpy(dest, src);

   printf("String final : %s\n", dest);

   return(0);
}
', sizeof(dest)); strcpy(src, "Hola buenos días"); strcpy(dest, src); printf("String final : %s\n", dest); return(0); }

This prints "Final String: Hello, good morning"

    
answered by 28.04.2016 / 11:49
source