Skip to content

Instantly share code, notes, and snippets.

@valbaca
Created December 2, 2016 00:16
Show Gist options
  • Save valbaca/4dd7a123ace1cfe562b77fd12d2a51c7 to your computer and use it in GitHub Desktop.
Save valbaca/4dd7a123ace1cfe562b77fd12d2a51c7 to your computer and use it in GitHub Desktop.
char cId[5];
if (id < 10) {
sprintf(cId, "000%d", id);
} else if (id < 100) {
sprintf(cId, "00%d", id);
} else if (id < 1000) {
sprintf(cId, "0%d", id);
} else {
sprintf(cId, "%d", id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment