Advertisement
paulogp

str_copy

Aug 13th, 2011
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. // apple xcode
  2. // paulogp
  3.  
  4. /* str_copy: copy one string to other (=strcpy) */
  5. #include <stdio.h>
  6.  
  7. #define MAX_VECT_LENGTH 50
  8.  
  9. char *str_copy (char *the_destiny, char *the_origin);
  10.  
  11. char *str_copy (char *the_destiny, char *the_origin)
  12. {
  13.     int i = 0;
  14.    
  15.     while ((the_destiny[i] = the_origin[i]))
  16.         i++;
  17.  
  18.     return the_destiny;
  19. }
  20.  
  21. int main (int argc, const char * argv[])
  22. {
  23.     char the_vector_a[MAX_VECT_LENGTH];
  24.     char the_vector_b[MAX_VECT_LENGTH];
  25.    
  26.     // get number
  27.     printf("texto: ");
  28.     fgets(the_vector_a, MAX_VECT_LENGTH, stdin);
  29.    
  30.     // calculus
  31.     str_copy(the_vector_b, the_vector_a);
  32.    
  33.     printf ("copia: %s\n", the_vector_b);
  34.    
  35.     return (0);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement