ขอผู้รู้ช่วยดูให้หน่อยค่ะ เกี่ยวกับภาษาซี

มัน Run ไม่ได้ค่ะ ช่วยดูให้หน่อยนะค่ะว่าผิดตรงไหน ขอบคุณมากๆๆค่ะ

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <string.h>



  struct s {



  float weight;

  float weight1;

  float m;

  };



int main()

{



   int y1;

   int y2;

   int m1;

   int m2;

   int d1;

   int d2;

   int i,j,n,type;

   int choice;

   int count = 0;

   float sum = 0,avg,p,sum1 = 0,avg1,p1,dat1,dat2;

   int yy;

   int x=0,c;

   float m;

   float weight,weight1;



   struct s a[n],b[n];



   FILE *fptr;



     loop:



     printf("\n*********######## Body Weight Management Program #######*********\n");

     printf("\n\n1. Write data \n2. Read data \n3. Exit \n");

     scanf("%d",&choice);

    

     switch(choice)

     {

     case 1:

     printf("\n\nWrite data\n\n");

     printf("\nEnter Size of the loop: ");

     scanf("%d",&n);



     fptr=fopen("file.txt","wb");

     fflush(stdin);



     for(i = 0; i < n; i++){

     printf("\n Enter your target weight: ");

     scanf("%f",&a.weight);

     printf("\n\n Enter Size of the loop of number days: ");

     scanf("%f" ,&a.m);



     for(j = 0; j < a.m; j++){

     printf("\n\n Date[%d]: Your body weight =  " ,j+1);

     scanf("%f" ,&a[j].weight1);

     }

     sum += a[j].weight1;

     }

    

     avg = sum/m;

     p = avg/weight;

     dat2 = p*m;

     dat1 = m - dat2;



     printf("\n\n Probability = %.2f" ,p);

     printf("\n\n You have time = %.2f" ,dat1);

    

     fwrite(a,sizeof(a),n,fptr);

     fclose(fptr);

    

     break;

    

     case 2:

     printf("\n\nRead data\n\n");

    

     fptr=fopen("file.txt","rb");

     fread(b,sizeof(b),n,fptr);

    

     for(i = 0; i < n; i++){

     for(j = 0; j < b.m; j++){

     printf("\n\n Your target weight: %.2f" ,b.weight);

     printf("\n\n Dates[%d]: Your body weight = %.2f" ,j+1,b[j].weight1);

     }

    

     if(b.m > dat2){

     printf("\n\n Your weight should be the target.");

     }

     else{

     printf("\n\n You can not add weight to the target.");

     }

     }

     printf("\n\n You have time = %.2f" ,dat1);

    

     fclose(fptr);

    

     break;

    

     case 3:

     printf("\n\nExit\\n\n");

     exit(0);

     }

    

     goto loop;

     getch();

}
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่