Skip to content

Instantly share code, notes, and snippets.

@guangxuanliu
Created October 19, 2022 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guangxuanliu/c62d266399920f5023f0175255bd49ba to your computer and use it in GitHub Desktop.
Save guangxuanliu/c62d266399920f5023f0175255bd49ba to your computer and use it in GitHub Desktop.
#define m 16
char buffer[m] = {0};
int index = 0;
void fillBuffer(const char *buf, int n)
{
if(index + n <= m)
{
memcpy(buffer + index, buf, n);
index += n;
}
else
{
memcpy(buffer + index, buf, m - index);
//print here
index = 0;
fillBuffer(buffer, n - (m - index));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment