Könnte mir irgendwann jemand freundlicherweise mitteilen, wie wichtige Dateieingaben und -ausgaben in C durchgeführt werden sollen. Ich habe versucht, zu scannen, aber ich konnte nur Antworten für C++ und so weiter bekommen.

Ich versuche, fscanf und fprintf zu verwenden, um dies zu tun. Das Programm stürzt jedoch ab, sobald es diesen Teil ausführt, mit der Fehlermeldung: „Unbehandelte Ausnahme bei 0x50D39686 (msvcr120d.dll) in Test Project.exe: 0xC0000005: Zugriffsverletzung beim Schreiben von Speicherort 0xCCCCCCCC.

HTML-Code:
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()

{
    double things_in_file[6];
int counter;
FILE *file_cats;

if ((file_cats = fopen("cats.txt", "r")) == NULL)
{
    printf("This file doesn't exist.\n");
    system("pause");
    exit(-1);
}

for (counter = 0; counter <= 5; counter = counter + 1)
{

    fscanf(file_cats, "%lf\n", &things_in_file[counter]);
    printf("%f\n", things_in_file[counter]);

}

fclose("file_cats");
system("pause");

exit(0);
Can somebody Please help with this?