summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/readch.c
blob: 8287efd21a91088b3ef862a56494bbbee7cc0d59 (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
/*
 * Purpose: Program to demonstrate the 'getchar' function.
 *	The prog will read data entered via the keyboard. And return
 *	the number of characters entered. 
 * Author:  M J Leslie
 * Date:    08-May-94
 */

#include <stdio.h>
#include <unistd.h>

int readch(void);

main()
{
  printf("%c",readch()+1);
}

int readch(void)
{
  char ch;

  read(0, &ch, 1);
  return (ch);
}