Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include "pch.h"
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7.  
  8. void concatString (char szTarget[], char szSource[]);
  9.  
  10. int main() {
  11. setlocale (LC_ALL, "RUS");
  12. char szString1[256];
  13. cout << "Введите строку №1: ";
  14. cin.getline (szString1, 128);
  15.  
  16. char szString2[128];
  17. cout << "Введите строку №2: ";
  18. cin.getline (szString2, 128);
  19.  
  20. char line[1] = {' - '};
  21.  
  22. concatString (szString1, line);
  23.  
  24. concatString (szString1, szString2);
  25.  
  26. cout << "\n" << szString1 << "\n";
  27.  
  28. return 0;
  29. }
  30.  
  31. void concatString (char szTarget[], char szSource[]) {
  32. int targetIndex = 0;
  33.  
  34. while (szTarget[targetIndex]) {
  35. targetIndex++;
  36. }
  37.  
  38. int sourceIndex = 0;
  39.  
  40. while (szSource[sourceIndex]) {
  41. szTarget[targetIndex] = szSource[sourceIndex];
  42. targetIndex++;
  43. sourceIndex++;
  44. }
  45.  
  46. szTarget[targetIndex] = '\0';
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement