Skip to content

Instantly share code, notes, and snippets.

@sproctor
Created January 11, 2014 18:26
Show Gist options
  • Save sproctor/8374723 to your computer and use it in GitHub Desktop.
Save sproctor/8374723 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main (int argc, char **argv) {
char *str;
long n;
if (argc < 2) {
printf ("Pass the number you want incremented.\n");
return -1;
}
str = argv[1];
n = strtol (str, (char **)NULL, 10);
{
char *tmp, *format;
asprintf(&format, "%%%ss ", str);
asprintf(&tmp, format, " ");
n = strlen(tmp);
}
printf("number: %ld\n", n);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment