Student registration and marklist program

Hi can I ask why my c++ code output file generated doesn’t in proper layout (txt. file) and its affecting other feature of my student registration programs like Delete_student, sort, search and ranklist. I am a freshman that’s why I don’t know where is wrong. Thanks in advance. I enter different website to seek for help but no one help me.
This is my code:

#include<iostream>
#include<fstream>
#include<string>
#include<map>
using namespace std;

struct student_profile {
    char FName[100];
    char LName[100];
    char reg_year[100];
    char course[100];
    char id[100];
    int no_courses;
    char course_Name[100];
    char course_code[100];
    int credit_hour;
    int quiz_one;
    int quiz_two;
    int quiz_three;
    int mid;
    int assignment;
    int lab;
    int final_exam;
    int uid;
    int t = 1;
};

map < int, string > data;
map < int, int > mark;

student_profile student;
fstream storage;

void function_to_register() {
    cout << "\n  Write First Name of student: ";
    cin >> student.FName;
    cout << "  Write Last Name of student: ";
    cin >> student.LName;
    cout << "  Write Registration year: ";
    cin >> student.reg_year;
    cout << "  Write id: ";
    cin >> student.uid;
    cout << "  Write Course of student: ";
    data[student.uid] = student.FName;
    cin >> student.course;
    cout << "  Write number of courses that student learns in this semester and register them one by one. \n";
    cout << "  Number of courses: ";

    cin >> student.no_courses;
    for (int a = 1; a <= student.no_courses; a++) {
        cout << "\n   Write course Name: ";
        cin >> student.course_Name;
        cout << "   Enter grade for quiz one: ";
        cin >> student.quiz_one;
        cout << "   Enter grade for quiz two: ";
        cin >> student.quiz_two;
        cout << "   Enter grade for quiz three: ";
        cin >> student.quiz_three;
        cout << "   Enter midterm grade: ";
        cin >> student.mid;
        cout << "   Enter assignment grade: ";
        cin >> student.assignment;
        cout << "   Enter lab grade: ";
        cin >> student.lab;
        cout << "   Enter final exam grade: ";
        cin >> student.final_exam;

        int totalMark;
        totalMark = (student.quiz_one + student.quiz_two + student.quiz_three + student.assignment + student.mid + student.final_exam) / 6;
        mark[student.uid] = totalMark;

        storage.open("marklist.txt", ios::app);
        storage.write((char * ) & student, sizeof(student));
        storage.close();
    }
}

void grade_calculator(int totalMark) {
    if (totalMark >= 90 && totalMark <= 100)
        cout << "A+";
    else if (totalMark >= 80 && totalMark < 90)
        cout << "A";
    else if (totalMark >= 70 && totalMark < 80)
        cout << "B";
    else if (totalMark >= 60 && totalMark < 70)
        cout << "C+";
    else if (totalMark >= 50 && totalMark < 60)
        cout << "D";
    else if (totalMark >= 0 && totalMark < 50)
        cout << "F";
    else
        cout << "NG";
}

void seeRegistered() {
    string word, filename;
    storage.open("marklist.txt", ios:: in );
    storage.read((char * ) & student, sizeof(student));
    while (storage.eof() == 0) {
        cout << "\n\n\n ";
        if (student.t == 0) {
            cout << "Record not found." << endl;
            break;
        }

        cout << " Full Name: " << student.FName << " " << student.LName << endl;
        cout << " Registration Year: " << student.reg_year << endl;
        cout << " Faculty: " << student.course << endl;
        cout << " Student ID No.: " << student.uid << endl;
        cout << " ***************************************************************************** \n";
        cout << " ******************************STUDENT MARK LIST****************************** \n";
        cout << " ***************************************************************************** \n";
        cout << " Subject   Quiz1 Quiz2 Quiz3 Mid Assignment Final Total Grade \n";
        cout << " _____________________________________________________________________________ \n";

        for (int t = 1; t <= student.no_courses; t++) {
            int totalMark;
            totalMark = (student.quiz_one + student.quiz_two + student.quiz_three + student.assignment + student.mid + student.final_exam) / 6;

            cout << " " << student.course_Name << "          " << student.quiz_one << "    " << student.quiz_two << "    " << student.quiz_three << "    " << student.mid << "    " << student.assignment << "       " << student.final_exam << "    " << totalMark << "    ";

            grade_calculator(totalMark);
            cout << endl;
            storage.read((char * ) & student, sizeof(student));
        }
    }
    storage.close();
}

void search_student(int id) {
    storage.open("marklist.txt", ios::in);
    storage.read((char * ) & student, sizeof(student));
    while (storage.eof() == 0) {
        
        if (student.uid == id && student.t) {
            cout << " ";
            cin >> student.FName;

            cout << " Full Name: " << student.FName << " " << student.LName << endl;
            cout << " Registration Year: " << student.reg_year << endl;
            cout << " Faculty: " << student.course << endl;
            cout << " Student ID No.: " << student.uid << endl;

            cout << " ***************************************************************************** \n";
            cout << " ******************************STUDENT MARK LIST****************************** \n";
            cout << " ***************************************************************************** \n";
            cout << " Subject   Quiz1 Quiz2 Quiz3 Mid Assignment Final Total Grade \n";
            cout << " _____________________________________________________________________________ \n";

            for (int t = 1; t <= student.no_courses; t++) {

                int totalMark;

                totalMark = (student.quiz_one + student.quiz_two + student.quiz_three + student.assignment + student.mid + student.final_exam) / 6;
                cout << " " << student.course_Name << "          " << student.quiz_one << "    " << student.quiz_two << "    " << student.quiz_three << "    " << student.mid << "    " << student.assignment << "       " << student.final_exam << "    " << totalMark << "    ";

                grade_calculator(totalMark);

                cout << endl;

                storage.read((char * ) & student, sizeof(student));
            }

        } else {

            storage.close();
            cout << " Student not found." << endl;
            break;
        }
    }
    storage.close();
}

void delete_student(int id) {
    storage.open("marklist.txt", ios::in);
    bool f = false;
    storage.read((char * ) & student, sizeof(student));
    while (storage.eof() == 0) {
        cout << "";
        if (student.uid == id) {
            storage.open("marklist.txt", ios::app);
            cout << " Enter 0 for delete" << endl;
            cin >> student.t;
            storage.open("marklist.txt", ios::app);
            storage.write((char * ) & student, sizeof(student));
            //storage.write(student,sizeof(student));
            f = true;
            cout << " Record has been deleted." << endl;
            storage.close();
            break;
        }
        storage.close();
    }
    if (!f)
        cout << " Student not found." << endl;
}
//===
#include<string.h>

void Edit_student(int id) {
    storage.open("marklist.txt", ios::in);
    bool f = false;
    storage.read((char * ) & student, sizeof(student));

    while (storage.eof() == 0) {
        if (student.uid == id && student.t) {
            char f1[100];
            cout << " Enter First Name to edit: ";
            cin >> student.FName;
            cout << " Enter Last Name to edit: ";
            cin >> student.LName;
            cout << " Enter registration year to edit: ";
            cin >> student.reg_year;
            cout << "";
            cout << " Full Name: " << student.FName << " " << student.LName << endl;
            cout << " Registration Year: " << student.reg_year << endl;
            cout << " Faculty: " << student.course << endl;
            cout << " Student ID No.: " << student.uid << endl;
            cout << " ***************************************************************************** \n";
            cout << " ******************************STUDENT MARK LIST****************************** \n";
            cout << " ***************************************************************************** \n";
            cout << " Subject  Quiz1 Quiz2 Quiz3 Mid Assignment Final Total Grade \n";
            cout << " _____________________________________________________________________________ \n";

            for (int t = 1; t <= student.no_courses; t++) {
                int totalMark;
                totalMark = (student.quiz_one + student.quiz_two + student.quiz_three + student.assignment + student.mid + student.final_exam) / 6;

                cout << " " << student.course_Name << "          " << student.quiz_one << "    " << student.quiz_two << "    " << student.quiz_three << "    " << student.mid << "    " << student.assignment << "       " << student.final_exam << "    " << totalMark << "    ";

                grade_calculator(totalMark);

                cout << endl;

                storage.write((char * ) & student, sizeof(student));
                //storage.write(student,sizeof(student));
                f = true;
                storage.close();
                cout << "Record has been editted." << endl;
                break;
            }
        }
        if (!f)
            cout << "Student not found." << endl;
        break;
    }
    storage.close();
}

//==
#include<algorithm>
#include<vector>
#include<iterator>

void SortStudent() {
    vector < int > a;
    map < int, string > ::iterator it;
    for (it = data.begin(); it != data.end(); it++) {
        a.push_back(it -> first);
    }
    sort(a.begin(), a.end());
    cout << "After sorting name or id \n";
    for (int it = 0; it < a.size(); it++) {
        cout << data[a[it]] << " " << a[it] << endl;
    }
}

#include<algorithm>
#include<vector>
#include<iterator>

void ranklist() {
    map < int, int > ::iterator it;
    for (it = mark.begin(); it != mark.end(); it++) {
        int totalMark = it -> second;
        cout << "\nName of student: " << data[it -> first] << " " << "Grade is: ";
        if (totalMark >= 90 && totalMark <= 100)
            cout << "A+" << "Under Rank -> 1" << endl;
        else if (totalMark >= 80 && totalMark < 90)
            cout << "A" << "Under Rank -> 2" << endl;
        else if (totalMark >= 70 && totalMark < 80)
            cout << "B" << "Under Rank -> 3" << endl;
        else if (totalMark >= 60 && totalMark < 70)
            cout << "C+" << "Under Rank -> 4" << endl;
        else if (totalMark >= 50 && totalMark < 60)
            cout << "D" << "Under Rank -> 5" << endl;
        else if (totalMark >= 0 && totalMark < 50)
            cout << "F" << "Under Rank -> 6 and fail in exam" << endl;
        else
            cout << "NG";
    }
}

int main() 
{
    char select;
    while (1) {
        cout << endl;
        cout << endl;
       
        cout << "   ------------------------------------------------------ \n";
        cout << "         STUDENT REGISTRATION AND MARK LIST SYSTEM  \n";
        cout << "   ------------------------------------------------------- \n";
        cout << "   Enter 1 To Register New student \n";
        cout << "   Enter 2 To Show Registerd Students and Grade \n";
        cout << "   Enter 3 To Search for a student \n";
        cout << "   Enter 4 To Edit a student record \n";
        cout << "   Enter 5 To Delete a student record \n";
        cout << "   Enter 6 To Sort student a student record \n";
        cout << "   Enter 7 To Rank a student record \n";
        cout << "   Enter 0 To Exit ";

        cout << "\n   Please Enter: ";
        cin >> select;
        switch (select) {
        case '1':
            function_to_register();
            cout << "\n   Student Registered successfully. ";
            break;
        case '2':
            seeRegistered();
            break;
        case '3':
            int id;
            cout << "Enter student id: " << endl;
            cin >> id;
            search_student(id);
            break;
        case '4':
            int id1;
            cout << "Enter student id: " << endl;
            cin >> id1;
            Edit_student(id1);
            break;
        case '5':
            int it;
            cout << "Enter student id: " << endl;
            cin >> it;
            delete_student(id);
            break;
        case '6':
            cout << "Sort student" << endl;
            SortStudent();
            break;
        case '7':
            cout << "Rank student" << endl;
            ranklist();
            break;
        case '0':
            exit(0);
            break;
        }
    }
}

The code is running. Only issue is writing the structure to the file. You can try another way to write to the file.