Skip to content

Instantly share code, notes, and snippets.

@int0x33
Created February 17, 2019 12:24
Show Gist options
  • Select an option

  • Save int0x33/d95af4eb415f3f0ad8a2e76297e18fd9 to your computer and use it in GitHub Desktop.

Select an option

Save int0x33/d95af4eb415f3f0ad8a2e76297e18fd9 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
enum { BUFFER_SIZE = 10 };
int main() {
char buffer[BUFFER_SIZE];
int length = snprintf(buffer, BUFFER_SIZE, "%s%s", "long-name", "suffix");
if (length >= BUFFER_SIZE) {
/* handle string truncation! */
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment