I wrote a code to read Data from a file and its compiling without a problem but when I try to run it a window opens and I get the error:
programm has stopped working
How can I fix that?
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


struct Koordinaten
{
double x;
double y;
double t;
int length;
};


struct Koordinaten *read_Data(FILE* input,int *size)
{
struct Koordinaten *res;
double zwisch1,zwisch2,zwisch3; 
int i;
    for(i=0;;i++)//count entrys
    {
        if(EOF==fscanf(input,"%lf %lf %lf",&zwisch1, &zwisch2,&zwisch3))
        break;
    }
*size = i;


(*res).length = *size;








res=malloc(*size*sizeof(struct Koordinaten));
    if(res==NULL)
    {
    perror("No memory reserved");
    return 0;
    }
rewind(input);


    for(i=0;i<*size;i++)
    {
    fscanf(input,"%lf %lf %lf",&(res[i].t),&(res[i].x),&(res[i].y));
    printf("X: %lf\n Y: %lf\n",res[i].x,res[i].y);
    }
fclose(input);
return res;
}




int main(int argc, char **argv)
{
FILE *inp;
int s;
struct Koordinaten *B;


    
    if(argc==1)
    {
    inp=stdin;
    }
    else if (argc==2)
    {
    inp=fopen(argv[1],"r");
    B = read_Data(inp,&s);
    }
    else 
    {
        printf("invalid parameter");
        exit(1);
       }
     if (inp==NULL)
    {
    printf("file %s could not be opend\n",argv[1]);
    exit(2);
    }
    //printf("INPUT: %s %i",argv[1],argc);


 
return 0;
}