Skip to content

Instantly share code, notes, and snippets.

@guswns0528
Created January 28, 2015 13:49
Show Gist options
  • Save guswns0528/7788f6f1555fcfbbd4ff to your computer and use it in GitHub Desktop.
Save guswns0528/7788f6f1555fcfbbd4ff to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cstring>
extern "C" {
#include <unistd.h>
}
constexpr int row = 23;
constexpr int column = 80;
char backbuffer[2000];
char get(int x, int y)
{
return backbuffer[column * y + x];
}
void set(int x, int y, char c)
{
backbuffer[column * y + x] = c;
}
void init()
{
memset(backbuffer, ' ', sizeof(backbuffer));
backbuffer[row * column] = '\0';
}
int main(void)
{
init();
for (int i = 0; i < row; i++)
{
set(0, i, 'a' + i);
}
while (true)
{
printf("%s", backbuffer);
fflush(stdout);
usleep(1000000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment