0. initialize all global variables.
char deleteid[12] = {0};
char updateid[12] = {0};
char data_tc_idno[12] = {0};
char data_id[13] = {0};
char data_adress[30] = {0};
char data_name[30] = {0};
char data_telno[12] = {0};
int deleteStatus[30] = {0};
struct student list2014[30] = {0};
1. rename your
typedef struct list
to
struct student
. The name "list" is misleading. Something like "student" should be more clear to anyone reading your code. You reference the type as a struct, so the typedef does nothing for you.
2. load: read your whole student list "list2014" from a file; for each student, set deleteStatus[index] to some value to indicate that slot is loaded and valid. Call this once before printing menu.
3. print: print the full list to the console - from "list2014", not from a file. This function should skip student records marked as deleted (see "deleteStatus") or unused.
4. to delete a student, find the student's index in list2014 and use that index to set deleteStatus[index] to a value than means "deleted".
This code is very messy:
key_command = _getch();
if (key_command == 'a' || key_command == 'A')
add_student();
else if (key_command == 'd' || key_command == 'D')
delete_student();
else if (key_command == 'l' || key_command == 'L')
list_student();
else if (key_command == 'q' || key_command == 'Q')
exit(0);
Use the toupper function to convert the letter to uppercase. This will simplify your if statements (even better: replace the if/else's with a switch statement).
key_command = toupper( _getch() );
if ('A' == key_command)
add_student();
else if ('D' == key_command)
delete_student();
else if ('L' == key_command)
list_student();
else if ('Q' == key_command)
exit(0);
5. save: write your full student list "list2014" to a different file - call this before exit. This function should skip student records marked as deleted (see "deleteStatus") or unused.
6. as a debugging aid, add a 'S' save command to call the save function so you can see the effects of each operation.
Good luck.