Skip to content

Instantly share code, notes, and snippets.

@mr-fool
Created June 19, 2014 16:51
Show Gist options
  • Select an option

  • Save mr-fool/46101232de2b026e70f4 to your computer and use it in GitHub Desktop.

Select an option

Save mr-fool/46101232de2b026e70f4 to your computer and use it in GitHub Desktop.
C printing ascii table without print buffer
#include <stdio.h>
int main(){
int i=0; //
while (i<=127){ /*227 = total number of asii value*/
if (i%8==0 ) {
printf("\n");
}
if ((i<=32) || (i==127) ){ /*Since 1-32 and 127 is non-printable*/
printf("%c",'.'); /*replace non-printable character with .*/
i++; /*move forward*/
}
else { /*if not special case then just print normally*/
printf("%c",i);
i++;
}
}
printf("\n");
return 0; /*Keep compiler happy*/
}
allFiles: ascii.c
gcc -Wall ascii.c -o ascii.out -lm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment