#include <cstring>
#include <iostream>
class A
{
unsigned char buffer[4096];
int position;
public:
A() : position(0)
{
memset(buffer, 0, 4096);
char *pos = reinterpret_cast<char*>(&(this->buffer[50]));
strcpy(pos, "String");
pos = reinterpret_cast<char*>(&(this->buffer[100]));
strcpy(pos, "An other string");
}
const char *ReadString()
{
if (this->position != 4096)
{
while (std::isalpha(this->buffer[this->position]) == false && this->position != 4096)
this->position++;
if (this->position == 4096)
return 0;
void *tmp = (&(this->buffer[this->position]));
char *str = static_cast<char *>(tmp);
this->position += strlen(str);
return (str);
}
return 0;
}
};
int main()
{
A test;
std::cout << test.ReadString() << std::endl;
std::cout << test.ReadString() << std::endl;
std::cout << test.ReadString() << std::endl;
}
I2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCmNsYXNzICAgQQp7CiAgdW5zaWduZWQgY2hhciBidWZmZXJbNDA5Nl07CiAgaW50ICAgcG9zaXRpb247CgpwdWJsaWM6CiAgQSgpIDogcG9zaXRpb24oMCkKICB7CiAgICBtZW1zZXQoYnVmZmVyLCAwLCA0MDk2KTsKICAgIGNoYXIgICAgICAgICpwb3MgPSByZWludGVycHJldF9jYXN0PGNoYXIqPigmKHRoaXMtPmJ1ZmZlcls1MF0pKTsKICAgIHN0cmNweShwb3MsICJTdHJpbmciKTsKICAgIHBvcyA9IHJlaW50ZXJwcmV0X2Nhc3Q8Y2hhcio+KCYodGhpcy0+YnVmZmVyWzEwMF0pKTsKICAgIHN0cmNweShwb3MsICJBbiBvdGhlciBzdHJpbmciKTsKICB9CgogIGNvbnN0IGNoYXIgKlJlYWRTdHJpbmcoKQogIHsKICAgIGlmICh0aGlzLT5wb3NpdGlvbiAhPSA0MDk2KQogICAgICB7CiAgICAgICAgd2hpbGUgKHN0ZDo6aXNhbHBoYSh0aGlzLT5idWZmZXJbdGhpcy0+cG9zaXRpb25dKSA9PSBmYWxzZSAmJiB0aGlzLT5wb3NpdGlvbiAhPSA0MDk2KQogICAgICAg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