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