//等级变化
char grade() {
FILE* file;
errno_t err = fopen_s(&file, USER_SEND_PARCEL_FILE, "r");
if (err != 0) {
printf("无法打开文件!\n");
return '0';
}
send_P* head=NULL;
char line[MAX_length * 9];
while (fgets(line, sizeof(line), file))
{
send_P* new_parcel = (send_P*)malloc(sizeof(send_P));
if (!new_parcel) {
printf("内存分配失败!\n");
return '0';
}
sscanf_s(line, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%s", new_parcel->user_id, new_parcel->type, new_parcel->quality, new_parcel->trans_company, new_parcel->num_send_a, new_parcel->num_send_b, new_parcel->address_a, new_parcel->address_b, new_parcel->state_send);
new_parcel->next = head;
head = new_parcel;
}
fclose(file);
int grade = 0;
int count = 0;
send_P* current = head;
while (current != NULL) {
count++;
current = current->next;
}
grade = count / 5+1;
if (grade > 5) {
grade = 5;
}
char g = grade + 48;
return g;
}
char grade() {
FILE* file;
errno_t err = fopen_s(&file, USER_SEND_PARCEL_FILE, "r");
if (err != 0) {
printf("无法打开文件!\n");
return '0';
}
send_P* head=NULL;
char line[MAX_length * 9];
while (fgets(line, sizeof(line), file))
{
send_P* new_parcel = (send_P*)malloc(sizeof(send_P));
if (!new_parcel) {
printf("内存分配失败!\n");
return '0';
}
sscanf_s(line, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%s", new_parcel->user_id, new_parcel->type, new_parcel->quality, new_parcel->trans_company, new_parcel->num_send_a, new_parcel->num_send_b, new_parcel->address_a, new_parcel->address_b, new_parcel->state_send);
new_parcel->next = head;
head = new_parcel;
}
fclose(file);
int grade = 0;
int count = 0;
send_P* current = head;
while (current != NULL) {
count++;
current = current->next;
}
grade = count / 5+1;
if (grade > 5) {
grade = 5;
}
char g = grade + 48;
return g;
}



