aboutsummaryrefslogtreecommitdiffstats
path: root/com32/samples/cat.c
blob: 277427fff1cd81f5a7fccda146549884d425f527 (plain)
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
30
31
#include <stdio.h>
#include <stdlib.h>
#include <console.h>

int main(int argc, char *argv[])
{
  FILE *f;
  int ch;
  int i;

  openconsole(&dev_stdcon_r, &dev_stdcon_w);

  printf("argv = %p\n", argv);
  for ( i = 0 ; i <= argc ; i++ )
    printf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]);

  if ( argc < 2 ) {
    fprintf(stderr, "Missing file name!\n");
    exit(1);
  }

  printf("File = %s\n", argv[1]);

  f = fopen(argv[1], "r");
  while ( (ch = getc(f)) != EOF )
    putchar(ch);

  fclose(f);

  return 0;
}