i got that program working and now trying to modify the previous function such that it only adds ‘n’ characters of the second parameter to the first. first of all i am having trouble passing the first output of string characters into main (i am not using any string functions as it is not allowed which is kind of a pain).
This is what i have
Code:
#include <iostream>
using namespace std;
int Number(int a, int b);
char Add(char*a, char*b, char*StrOut);
int main()
{
char a[3] = {'T','i','m'};
char b[7] = {'P','e','c','k','i','t','t'};
char StrOut[20];
cout << "Sum = " << Number(8,2) << endl;
int sum = Add(a,b,StrOut);
system ("pause");
}
int Number(int a, int b)
{
return a+b;
}
char Add(char* a, char* b, char* StrOut)
{
int i = 0;
while (a[i] != '\0')
{
StrOut[i] = a[i];
i ++;
}
StrOut[i] = ' ';
i++;
int j = 0;
while (b[j] != '\0')
{
StrOut[i] = b[j];
j ++;
i++;
}
StrOut[i] = '\0';
return StrOut[i];
}