Odpowiedź :
#include <iostream>
class string {
private:
char t[256];
public:
string()
{
t[0] = 0;
for (int i = 1; i < 256; i++)
{
t[i] = '\0';
}
}
string(const char* str)
{
int len = strlen(str);
t[0] = len;
for (int i = 0; i < len; i++)
{
t[i + 1] = str[i];
}
for (int i = len+1; i < 256; i++)
{
t[i] = '\0';
}
}
int len()
{
return t[0];
}
void cut(unsigned int pos, unsigned int len)
{
for (unsigned int i = pos + 1; i < t[0]; i++)
{
t[i] = t[i+len];
t[i+len] = '\0';
}
t[0] -= len;
}
void join(string a)
{
for (unsigned int i = t[0] + 1, j=1; i < a.len()+ t[0] + 1; i++, j++)
{
t[i] = a.t[j];
}
t[0] += a.t[0];
}
void show()
{
unsigned int p = 0;
while (t[++p])
{
std::cout << t[p];
}
}
};
int main()
{
string x("test1 test2 test3");
string y("test4 test5 test6");
x.join(y);
x.show();
return 0;
}