Yurttas/PL/IL/C/F-mar11/04/02/00/05/input.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 input.c
14*/
15
16
17#include <stdio.h>
18
19#include <string.h>
20
21#define MAX_SIZE_STRING 64
22
23int input(char *s[]) {
24 FILE *f_in;
25
26 char f_name[MAX_SIZE_STRING];
27
28 int i = 0;
29
30 printf("\n-> input filename : ");
31 scanf("%s", f_name);
32
33 f_in = fopen(f_name, "r");
34
35 if(!f_in) {
36 printf("\ncannot open %s\n", f_name);
37 exit(1);
38 }
39
40 s[i] = (char*) malloc(MAX_SIZE_STRING*sizeof(char));
41
42 while(fgets(s[i++], MAX_SIZE_STRING, f_in))
43 s[i] = (char*) malloc(MAX_SIZE_STRING*sizeof(char));
44
45 return i;
46}