This Mac mini was a bit of a bargain. £435 from eBay 4 years ago. The previous owner hadsn't deleted all his data from it, only his user account. All his apps were still on it, and some rather risque pics of his wife ... or mistress!
As for OpenCore Legacy Patcher ... I installed it on a 2009 model MacBook given to me by a friend. The MacBook currently runs macOS Ventura, but is now out of action since the offical Apple charger is goosed due to minor cable damage.
If that old Macbook comes out of retirement, it'll probably end up with Linux.
Question
togamonkey
Could someone explain to me what a segmentation fault is, and what is causing it within my program? I'd be grateful for any help! :D
#include <stdio.h> #define ARR 50 void Fill_Arrays(int ID[], int max, double score[], int *count); double average(const int score[], int count1); int main (void) { FILE *outp; outp = fopen("output.out", "w"); int ID[ARR], count = 0, input_status; double score[ARR], av; Fill_Arrays(ID, ARR, score, &count); av= average(score[], count); fclose(outp); return (0); } void Fill_Arrays (int ID[], int max, double score[], int *count) { FILE *inp; int input_status, data1; double data2; inp = fopen("assignment8.dat", "r"); input_status= fscanf(inp, "%d%lf", data1, data2); while (input_status != EOF && *count < max){ ID[*count] = data1; score[*count] = data2; *count++; input_status= fscanf(inp, "%d&lf", data1, data2); } fclose(inp); } double average(const int score[], int count1) { int counter; double sum=0, average; for (counter = 0; counter <= count1; counter++) sum+=score[counter]; average=sum/count1; return (average); }
Edited by togamonkeyLink to comment
https://www.neowin.net/forum/topic/327665-c-segmentation-fault-core-dumped/Share on other sites
3 answers to this question
Recommended Posts