fix:finish delete

main
theBao 1 year ago
parent 4dfff61c02
commit 5725d46670

@ -3,7 +3,7 @@
void cancel(ss*stu){ void cancel(ss*stu){
char* tmp = (char*)malloc(sizeof(char)*3); char* tmp = (char*)malloc(sizeof(char)*3);
do{ do{
char*ID = (char*)malloc(sizeof(char)*5); char*ID = (char*)malloc(sizeof(char)*6);
scanf("%s",ID); scanf("%s",ID);
for(int i = 0; i < stu->nums; ++i){ for(int i = 0; i < stu->nums; ++i){
if(strcmp(stu->student[i].id,ID) == 0){ if(strcmp(stu->student[i].id,ID) == 0){
@ -12,6 +12,7 @@ void cancel(ss*stu){
} }
} }
} }
stu->nums--;
allPrint(stu); allPrint(stu);
printf("continue?\n"); printf("continue?\n");
scanf("%s",tmp); scanf("%s",tmp);

@ -1,4 +1,4 @@
#include "mysyslib.h" w#include "mysyslib.h"
ss* init(int Nums){ ss* init(int Nums){
ss* stu = (ss*)malloc(sizeof(ss)); ss* stu = (ss*)malloc(sizeof(ss));
@ -9,8 +9,8 @@
if(!stu->student) return NULL; if(!stu->student) return NULL;
for(int i = 0; i < Nums; ++i){ for(int i = 0; i < Nums; ++i){
stu->student[i].id = (char*)malloc(sizeof(char)*5); stu->student[i].id = (char*)malloc(sizeof(char)*6);
stu->student[i].class = (char*)malloc(sizeof(char)*2); stu->student[i].class = (char*)malloc(sizeof(char)*3);
stu->student[i].name = (char*)malloc(sizeof(char)*10); stu->student[i].name = (char*)malloc(sizeof(char)*10);
} }

Loading…
Cancel
Save