Encoders
>
More...
>
C
>
Program
/* Program that prints arbitrary input in a sensible way.
It prints non-graphic character in hexadecimal and break
long text lines. */
#include <stdio.h>
#include <ctype.h>
#define MAXLINE 5
main()
{
int i=0,c;
printf(
while((c=getchar())!=EOF)
{
if(iscntrl(c)||c==' ')
{
if(i+2>=MAXLINE)
{
printf("\n");
i=0;
}
printf("\\%2x",c);
i+=3;
}
else
{
if(i>=MAXLINE)
{
printf("\n");
i=0;
}
putchar(c);
i++;
}
}
}
|