File: touint8array.c

package info (click to toggle)
sqlite3 3.46.1-7
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,660 kB
  • sloc: ansic: 281,304; tcl: 19,550; javascript: 12,978; sh: 10,768; java: 8,151; makefile: 1,690; yacc: 1,644; cpp: 440; cs: 307; sql: 45
file content (29 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
** 2023-08-29
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains a tool for writing out the contents of stdin as
** a comma-separated list of numbers, one per byte.
*/

#include <stdio.h>
int main(int argc, char const **argv){
  int i;
  int rc = 0, colWidth = 30;
  int ch;
  printf("[");
  for( i=0; EOF!=(ch = fgetc(stdin)); ++i ){
    if( 0!=i ) printf(",");
    if( i && 0==(i%colWidth) ) puts("");
    printf("%d",ch);
  }
  printf("]");
  return rc;
}