I have been debugging this simple c++ program for hours but I cannot figure out why it writes garbage values in to text file.
when I use fwrite to write data struct to "users.txt" file it looks like this after the program exited.
Dan ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌTest ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌTEST ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ4 ÌÌÌÌÌÌÌÌÌÌÌ TEST ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌTEST ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
This is the related code
struct student {
    int i_number;
        char first_name[50], last_name[50];
        char Address[75];
        char Date_Inquiry[11];
        int Tp;
        char Qual[100];
        char Email[50];
        int Age;
    };
struct student e;
recsize = sizeof(e);
fp = fopen("users.txt","w+");
another ='Y';
            while(another == 'Y' || another == 'y')
            {
                  system("cls");
                cout << "\n";
                cout << "\t INQUIRE NUMBER : ";
                cin >> e.i_number;
                cout << "\n\t FIRST NAME : ";
                cin >> e.first_name;
                cout << "\n\t LAST NAME : ";
                cin >> e.last_name;
                cout << "\n\t DATE OF INQUIRY : ";
                cin >> e.Date_Inquiry;
                cout << "\n\t ADDRESS : ";
                cin >> e.Address;
                cout << "\n\t CONTACT NO : ";
                cin >> e.Tp;
                cout << "\n\t QUALIFICATION : ";
                cin >> e.Qual;
                cout << "\n\t EMAIL : ";
                cin >> e.Email;
                cout << "\n\t AGE   : ";
                cin >> e.Age;
                fwrite(&e,recsize,1,fp);
                fflush(stdin);
                cout << "\n Add Another Record (Y/N) ";
                another = getchar();
            }
 fclose(fp);
please could you give me hints to figure out what's going on ?
 
    