#include<stdio.h>
#include<iostream>
using namespace std;
#include<fstream>
struct employee {
char name[25];
int marks;
float stipend;
};
int main()
{
employee e[2];
for(int i=0;i<2;i++)
{
cout<<"please enter name"<<endl;
cin>>e[i].name;
cout<<"enter marks"<<endl;
cin>>e[i].marks;
cout<<"enter stipend"<<endl;
cin>>e[i].stipend;
}
for(int x=0;x<2;x++)
{
cout<<" name marks and stipend are"<<e[x].name<<e[x].marks<<e[x].stipend<<endl;
}
fstream fileobj;
fileobj.open("myfile",ios::in|ios::out);
for (int k=0;k<2;k++)
{
fileobj.write((char*)(&e[k]),sizeof(e[k]));
}
please enter name
venkat
enter marks
56
enter stipend
7666
please enter name
prasad
enter marks
454
enter stipend
7684
name marks and stipend arevenkat567666
name marks and stipend areprasad4547684
reading from file
-1081492972
-1.07599
-1081492972
-1.07599
can someone help as to why its not wrting and reading into the file exatly..??
I am new to c++ please help