Zdravím, prosím vás v tomto príklade by som chcel aby sa mi spojili reťazce, ale nejako mi to nejde..
Viem, že sa to dá cez cstring,ale chcem pochopiť princip.
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char *a=new char[2];
char *b=new char[4];
strncpy(a,"lt",2);
strncpy(b,"name",4);
int MAX=strlen(a) + strlen(b);
char *c=new char[MAX];
cout << "Pocet znakov: " << MAX <<endl;
for(int i=0;i<MAX;i++)
{
if (i<strlen(a)) c[i]=a[i];
else c[i]=b[i];
}
cout << c << endl;
cout << *(c+9);
delete []a;
delete []b;
delete []c;
return 0;
}