Yurttas/PL/IL/C/F-mar11/03/01/04/02/get char.c
Jump to navigation
Jump to search
1/*
2 Copyright(C) 1998
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : January 1, 1998.
11 author : Salih Yurttas.
12
13 get_char.c
14*/
15
16
17#include <stdio.h>
18
19#define MAX_SIZE_STRING 64
20
21char get_char(char *s) {
22 FILE *in_file;
23 char filename[MAX_SIZE_STRING];
24
25 char a;
26
27 printf("\n-> input filename : ");
28 scanf("%s", filename);
29 printf("\n");
30
31 in_file = fopen(filename,"r");
32
33 if(in_file==NULL) {
34 printf("cannot open %s\n", filename);
35 exit(1);
36 }
37
38 fscanf(in_file, "%c", &a);
39
40 close(in_file);
41
42 return a;
43}