这里的结构体定义为啥不能用typedef

这里的struct定义为啥不能用typedef呢?
加了typedef会报错,提示不允许使用类型名
用的是vs
cpp的后缀


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
//#define MAXSIZE 30001

struct Student
{
    char id[15];
    int location;
    int local_rank;
    int score;
}stu[30001];

int main()
{
    
    int total_stu_per;//每个考场人数
    int total_location;//考场数
    int num = 0;//总人数
    scanf("%d", &total_location);
    for (int i = 1; i <= total_location; i++)
    {
        scanf("%d", &total_stu_per);
        for (int j = 0; i < total_stu_per; j++)
        {
            scanf("%s %d",stu[num].id, &stu[num].score);
            stu[num].location = i;
            num++;
        }
    }
    
    return 0;
}

这只是写法不同,就像你既可以说姥姥也可以说外婆,一个程序这么写或者那么写,都是一种选择和偏好而已,没有为什么
以上程序也可以用 typedef,只要合乎语法

 
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
//#define MAXSIZE 30001
 
typedef struct
{
    char id[15];
    int location;
    int local_rank;
    int score;
}Student;

Student stu[30001];
 
int main()
{
    
    int total_stu_per;//每个考场人数
    int total_location;//考场数
    int num = 0;//总人数
    scanf("%d", &total_location);
    for (int i = 1; i <= total_location; i++)
    {
        scanf("%d", &total_stu_per);
        for (int j = 0; i < total_stu_per; j++)
        {
            scanf("%s %d",stu[num].id, &stu[num].score);
            stu[num].location = i;
            num++;
        }
    }
    
    return 0;
}