Yurttas/PL/IL/C/F-mar11/01/02/00/08/get data.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_data.c
14*/
15
16
17#include <stdio.h>
18
19#define MAX_STRING_SIZE 64
20
21int get_data(char **a) {
22 FILE *in_file;
23 char filename[MAX_STRING_SIZE];
24
25 int i;
26
27 printf("\n-> input filename : ");
28 scanf("%s", filename);
29
30 in_file = fopen(filename,"r");
31
32 if(in_file==NULL) {
33 printf("cannot open %s\n", filename);
34 exit(1);
35 }
36
37 i = 0;
38 while(fscanf(in_file, "%s", a[i])!=EOF)
39 ++i;
40
41 fclose(in_file);
42
43 return i;
44}