#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
struct Screen{
char *thing;
int width;
int height;
struct TempStruct{
Screen *screen;
int x;
char& operator[](int y)
{
return screen->thing[y * screen->width + x];
}
};
TempStruct operator[](int x)
{
return TempStruct{this,x};
}
};
Screen screen_init(int width_in, int height_in)
{
Screen result;
result.thing = (char *)calloc(width_in * height_in + 1,1);
assert(result.thing);
result.width = width_in;
result.height = height_in;
return result;
}
int main() {
Screen test = screen_init(5,2);
for(int i = 0; i < test.width; ++i)
{
test[i][0] = "eple\n"[i];
test[i][1] = "pera\n"[i];
}
test[2][1] = 'T';
test[0][1] = test[2][0];
printf("%s",test.thing);
return 0;
}