#include<stdio.h>
#include<stdlib.h> //to do the exiting
//function to save
void save(STUDENT info){
FILE *savedfile; //pointer
savedfile=fopen("c:/database.txt","w"); //creates a file on drive "c" named "database.txt" to be written to
if(savedfile == NULL) //testing if file is opened
{printf(" Error opening output file");
exit(0);} //from the library stdlib.h. will exit if file is already opened
fprintf(savedfile,"%s, %s, %d, %s, %d", info.fname,info.lname,info.age,info.id,info.grade) ;//writes struct info to file
fclose(savedfile);//closes file after writing
}