Skip to content

Instantly share code, notes, and snippets.

@bynect
Created December 30, 2020 21:08
Show Gist options
  • Save bynect/c5dba6562da4cba67a2cc1885d6a62d3 to your computer and use it in GitHub Desktop.
Save bynect/c5dba6562da4cba67a2cc1885d6a62d3 to your computer and use it in GitHub Desktop.
A shell utility that prints the integer value of the given ascii characters.
/* ascii.c -- print the integer value of the given ascii chars */
/*
compilation:
cc ascii.c -o ascii
usage:
ascii your characters here [...]
*/
#include <stdio.h>
#include <string.h>
int
main(int argc, char **argv)
{
int i, j, l;
if (argc == 1)
return 1;
for (i = 1; i < argc; ++i) {
if (argc > 2)
printf("%s:\n", argv[i]);
for (j = 0, l = strlen(argv[i]); j < l; ++j)
printf("%c => %d\n", argv[i][j], argv[i][j]);
putchar('\n');
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment