Advertisement
brandonmunda1

Lavender_Task_10

Feb 27th, 2023
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include "main.h"
  2. /**
  3.  * _strcpy - copies one string to another
  4.  * @dest: destination string
  5.  * @src: source string
  6.  *
  7.  * Return: returns the copied string
  8.  */
  9. char *_strcpy(char *dest, char *src)
  10. {
  11.     int i = 0;
  12.     int j;
  13.  
  14.     while (1)
  15.     {
  16.         if (src[i])
  17.         {
  18.             i++;
  19.         }
  20.         else if (!src[i])
  21.         {
  22.             break;
  23.         }
  24.     }
  25.     /* printf("\n\nsrc has %d charachters\n\n", i); */
  26.  
  27.     for (j = 0; j < i; j++)
  28.     {
  29.         /* printf("\nAddress for src[%d] is %p\n", j, &(src[j])); */
  30.         dest[j] = src[j];
  31.         /* printf("\nAddress for dest[%d] is %p\n", j, &(dest[j])); */
  32.     }
  33.     dest[i] = '\0';
  34.     return (dest);
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement