Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdlib.h>
  2. int stringlen(char string[])
  3. {
  4. int i = 0;
  5. while(string[++i]);
  6. return i;
  7. }
  8. char *strcopy(char *st1)
  9. {
  10. int i = 0;
  11. char *string2 = malloc(sizeof(char[stringlen(st1)+1]));
  12. while(string2[i++])
  13. {
  14. string2[i] = *st1;
  15. st1++;
  16. }
  17. printf("%s", string2);
  18. return string2;
  19. }
  20.  
  21. int main()
  22. {
  23. char st1[] = "Name";
  24. char st2[] = "Henning";
  25.  
  26. stringlen(st1);
  27. strcopy(st1);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement