fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define MAXCHARS 8
  4. int chars[MAXCHARS];
  5. int ingroup;
  6. long cnt;
  7. int main() {
  8. void print_group(void);
  9. for(; (chars[ingroup] = getchar())!=EOF;cnt++)
  10. if(++ingroup == MAXCHARS)
  11. {
  12. print_group();
  13. ingroup = 0;
  14. }
  15. if(ingroup)
  16. print_group;
  17. return 0;
  18. }
  19. void print_group(void)
  20. {
  21. int i;
  22. void print_space(int c);
  23. printf("%06ld",cnt -ingroup + 1);
  24. for(i=0; i< ingroup;i++)
  25. printf("%03o",chars[i]);
  26. printf("\n");
  27. for(i=0;i<ingroup;i++){
  28. putchar(' ');
  29. if(isspace(chars[i]))
  30. print_space(chars[i]);
  31. else if(isprint(chars[i]))
  32. printf("%c",chars[i]);
  33. else
  34. printf(" ");
  35. }
  36. putchar('\n');
  37. }
  38. void print_space(int c)
  39. {
  40. int label;
  41. if(c==' ')
  42. printf(" ");
  43. else{
  44. switch(c)
  45. {
  46. case '\b' : label ='b'; break;
  47. case '\f' : label ='f'; break;
  48. case '\n' : label ='n'; break;
  49. case '\r' : label ='r'; break;
  50. case '\t' : label ='t'; break;
  51. case '\v' : label ='v'; break;
  52. default : label = '?'; break;
  53. }
  54. printf("\\%c",label);
  55. }
  56. }
  57.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty