Lỗi chương trình liên quan tới cấp phát động và struct

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct student{
	char ID[5];
	char Name[30];
};
typedef struct student student;

int Add(student *st,int n){
	st=(student *)calloc(n,sizeof(student));
	int i,j;
	for(i=0;i<n;i++){
	sub_main:
		
		printf("\nStudent %d\n",i+1);
		printf("ID:");
		gets(st[i]->ID);
		fflush(stdin);
		for(j=0;j<i;j++){
			if(strcmp(st[j]->ID,st[i]->ID)==0){
				printf("ID exited\n Please tye other ID\n");
				goto sub_main;
			}
		}
		printf("Name:");
		gets(st[i]->Name);
		fflush(stdin);
		printf("Score Hd:");
		scanf("%d",&st[i]->s.Hd);
		fflush(stdin);
    }
}

int List(student *st, int n){
	int i;
	printf("%-4s%-5s%-30s\n\n","Num","ID","Name");
	for(i=0;i<n;i++){
		printf("%-4d%-5s%-30s\n",i+1,st[i]->ID,st[i]->Name);
	}
}

int main(void){
	int ch,n;
	student *st;
main:	
	printf("\t=====MENU=====\n\n");
	printf("[1] Add student information\n");
	printf("[2] List\n");
	printf("\n\tNote: Maxinum of student: 20\n");
	printf("Chose:");
	scanf("%d",&ch);
	fflush(stdin);
	switch(ch){
		case 1:{
			system("cls");
			printf("Input data\n");
			do{
				printf("Number of student (max: 20): ");
			    scanf("%d",&n);
			    if(n>20){
			    	printf("Over limited\n Please type again\n");
				}
			}while(n>20);
			fflush(stdin);
			Add(st,n);
			break;
		}
		case 2:{
			system("cls");
			printf("List of student\n\n");
			List(st,n);
			break;
		}
	}
	printf("Do you want to continues\n [1] Yes--[0] No\n");
	printf("Chose:");
	scanf("%d",&ch);
	fflush(stdin);
	switch(ch){
		case 1:{
			system("cls");
			goto main;
			break;
		}
		case 2:{
			break;
		}
	}
	return 0;
}

mọi ngươi cop về dịch trong DEVC++ rồi debug hộ mình với

merged to #1 post by noname00

Không thể debug hộ được.

https://daynhauhoc.com/guidelines

Các chủ đề có nội dung sau sẽ bị khóa khi được đăng lên DNH:

  • Chủ đề trùng lặp.
  • Chủ đề là nhờ trợ giúp bài tập về nhà, bài thảo luận, hoặc một nhiệm vụ mà người tạo chủ đề phải tự mình hoàn thành.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?