#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
// prototype declarations
void concatString(char szTarget[], char szSource[]);
int main (int nArg, char* pszArgs[])
{
//read the first string
char szString1[256];
cout << "Enter string #1: ";
cin.getline(szString1, 128);
//now get the second string
char szString2[128];
cout << "Enter String #2: ";
cin.getline(szString2, 128);
//concatenate a "-" onto the first... (point1)
concatString(szString1, " ");
//strcat (szString1, " - ");
//now add the second string (point2)
concatString(szString1, szString2);
//strcat (szString1, szString2);
//and display the result
cout << "\n" << szString1 << "\n";
return 0;
}
//concatString - concatenate the szSource string on to the end of the szTarget
//string
void concatString(char szTarget[], char szSource[])
{
// Find the end of the first string
int targetIndex =0;
while (szTarget[targetIndex]) // (point3)
{
targetIndex++;
}
//tack the second on to the end of the first
int sourceIndex=0;
while (szSource[sourceIndex]) // (point4)
{
szTarget[targetIndex] = szSource[sourceIndex];
targetIndex++;
sourceIndex++;
}
//tack on the terminating null
szTarget[targetIndex]='\0';
}
Can somebody simply the function for me plz.
Thanks