Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. int lenght(const char *s)
  2. {
  3. int count = 0;
  4. while(*(s+count) != '\0')
  5. {
  6. count++;
  7. }
  8. return count;
  9. }
  10.  
  11. char *strconcat(const char *s, const char *t)
  12. {
  13. char buffer[lenght(s)+lenght(t)];
  14.  
  15. for(int i = 0; i != lenght(s); i++)
  16. {
  17. buffer[i] = s[i];
  18. }
  19.  
  20. for(int i = 0; i != lenght(t); i++)
  21. {
  22. buffer[lenght(s)+i] = t[i];
  23. printf("%d\n", i);
  24. }
  25.  
  26. buffer[lenght(s)+lenght(t)] = '\0';
  27.  
  28. return buffer;
  29. }
  30.  
  31.  
  32. char *strinv(const char *s)
  33. {
  34. int len = lenght(s);
  35. char buffer[len+1];
  36.  
  37. for(int i = 0; i != len; i++)
  38. {
  39. buffer[len-1-i] = s[i];
  40. }
  41. buffer[len] = '\0';
  42. return buffer;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement