[ create a new paste ] login | about

Link: http://codepad.org/ygCEytKA    [ raw code | output | fork ]

C, pasted on Jul 31:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int num, occ, arr, sum = 0, avr;
  FILE *fp;
  
  fp = fopen("data.txt", "r");
  while (fscanf(fp, "%d\t%d\t%d", &num, &occ, &arr) != EOF) {
    sum += arr;
  }
  fclose(fp);
  
  avr = sum / 100;
  
  fp = fopen("data1.txt", "w");
  fprintf(fp, "%d\n", avr);
  fclose(fp);
  
  return 0;
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: