Skip to content

Instantly share code, notes, and snippets.

@lotas
Created March 28, 2017 09:55
Show Gist options
  • Save lotas/0f4fa315331d8fae2a6de904c841e247 to your computer and use it in GitHub Desktop.
Save lotas/0f4fa315331d8fae2a6de904c841e247 to your computer and use it in GitHub Desktop.
strtoint.c colors
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc < 2) {
printf("No input\n");
return 1;
}
printf("Input: %s \n", argv[1]);
char *ptr;
long n = strtol(argv[1], &ptr, 10);
printf("Converted: \"%c[1;33m%s\" -> %c[1;31m%ld \n", 27, argv[1], 27, n);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment