Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <stdio.h>
- #include <locale.h>
- #include <iostream>
- #include <string>
- using namespace std;
- void concatString (char szTarget[], char szSource[]);
- int main() {
- setlocale (LC_ALL, "RUS");
- char szString1[256];
- cout << "Введите строку №1: ";
- cin.getline (szString1, 128);
- char szString2[128];
- cout << "Введите строку №2: ";
- cin.getline (szString2, 128);
- char line[1] = {' - '};
- concatString (szString1, line);
- concatString (szString1, szString2);
- cout << "\n" << szString1 << "\n";
- return 0;
- }
- void concatString (char szTarget[], char szSource[]) {
- int targetIndex = 0;
- while (szTarget[targetIndex]) {
- targetIndex++;
- }
- int sourceIndex = 0;
- while (szSource[sourceIndex]) {
- szTarget[targetIndex] = szSource[sourceIndex];
- targetIndex++;
- sourceIndex++;
- }
- szTarget[targetIndex] = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement