Skip to content

Instantly share code, notes, and snippets.

@bwolf
Created February 17, 2012 07:45
Show Gist options
  • Save bwolf/1851632 to your computer and use it in GitHub Desktop.
Save bwolf/1851632 to your computer and use it in GitHub Desktop.
snprintf error handling
int anint = 42;
char buf[42];
n = snprintf(lenbuf, sizeof(lenbuf), "%d:", anint);
if (!(n > -1 && n < sizeof(lenbuf))) {
perror("snprintf");
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment