Thêm 1 phần tử vào con trỏ struct

đề bài là nhập vào 1 loạt thông tin các học sinh, sau đó thêm 1 học sinh vào vị trí tự chọn. mọi người xem hộ em hàm them_phan_tu bị lỗi gì ạ. em cảm ơn
đây là kết quả khi chạy:

nhap so hoc sinh: 3

nhap thong tin hoc sinh:

nhap thong tin hoc sinh thu 1:
ten: a
nam sinh hoc sinh: 1
diem toan: 1

nhap thong tin hoc sinh thu 2:
ten: b
nam sinh hoc sinh: 2
diem toan: 2

nhap thong tin hoc sinh thu 3:
ten: c
nam sinh hoc sinh: 3
diem toan: 3
nhap vi tri muon them: 1

ten: d
nam sinh: 4
diem toan: 4

thong tin hoc sinh:

thong tin hoc sinh thu 1
ten: a
nam sinh hoc sinh: 1
diem toan: 1.0

thong tin hoc sinh thu 2
ten: d
nam sinh hoc sinh: 4
diem toan: 4.0

thong tin hoc sinh thu 3
ten: d
nam sinh hoc sinh: 4
diem toan: 4.0

sau đây là code:

#include<stdio.h>
#include<stdlib.h>
struct Student
{
    char name[100];
    int namsinh;
    float diem;
};
typedef struct Student student;
void nhap(student *s, int n){
    printf("\nnhap thong tin hoc sinh: ");
    for (int i = 0; i < n; i++)
    {
        printf("\n\nnhap thong tin hoc sinh thu %d: ",i+1);
        printf("\nten: ");fflush(stdin); gets((s+i)->name);
        printf("nam sinh hoc sinh: ");  scanf("%d",&(s+i)->namsinh);
        printf("diem toan: "); scanf("%f",&(s+i)->diem);
    }
    
}
void xuat(student *s, int n){
    printf("\n thong tin hoc sinh: ");
    for (int i = 0; i < n; i++)
    {
        printf("\n\nthong tin hoc sinh thu %d",i+1);
        printf("\nten: %s",(s+i)->name);
        printf("\nnam sinh hoc sinh: %d",(s+i)->namsinh); 
        printf("\ndiem toan: %.1f",(s+i)->diem);
    }
    
}
void them_phan_tu(student *s,student k, int n, int vitri){
    printf("\nten: "); fflush(stdin); gets(k.name);
    printf("nam sinh: "); scanf("%d",&k.namsinh);
    printf("diem toan: "); scanf("%f",&k.diem);
   
    n++;
    s=(student*)realloc(s,n*sizeof(student));
   
    for (int i = n; i > vitri; i--)
    {
       *(s+i)=*(s+i-1);
       *(s+vitri)=k;
    }
}
   
int main(){
    int n;
    printf("nhap so hoc sinh: ");
    scanf("%d",&n);
    
    student *s=(student*)malloc(n*sizeof(student));
    student k;
    
    nhap(s, n);
    
    printf("nhap vi tri muon them: ");
    int vitri;
    scanf("%d",&vitri);
    
    them_phan_tu(s,k,n,vitri);
   
    xuat(s,n);
    return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?