arsovski

String Cat Function

Feb 2nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<iostream>
  2. char * strCat(char *destination, const char*entered) {
  3. int length = 0;
  4. if (destination == "") {
  5. length = 0;
  6. }
  7. else {
  8. for (size_t i = 0; destination[i] != '\0'; i++)
  9. {
  10. length++;
  11. }
  12. }
  13. int i = 0;
  14. while (entered[i] != '\0') {
  15. destination[length + i] = entered[i];
  16. i++;
  17. }
  18. return destination;
  19. }
  20. int main()
  21. {
  22. char buffer[100]="";
  23. strCat(buffer, "dario");
  24. strCat(buffer, "e");
  25. strCat(buffer, "najjak");
  26. strCat(buffer, " ");
  27. std::cout << strCat(buffer, "covek");
  28. std::cin.get(); std::cin.get();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment