Created
March 24, 2016 16:13
-
-
Save oerdnj/db040b7f489d2ed84e27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
/* just make sure sizeof(out) is at least sz+1 large */ | |
#define left_pad(out, sz, s) snprintf(out, sz+1, "%.*s", sz, s) | |
#define left_pad_str(out, sz, s, pad) snprintf(out, sz+1, "%.*s%s", (sz < strlen(s)) ? 0 : sz - strlen(s), pad, s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment