my output file has random data when I write something on it,I checked multiple sources of writing object on a file and this seems correct still can't enter the right data
#include<bits/stdc++.h>
using namespace std;
namespace fs = std::filesystem;
class Events{
char eventName[90];
public:
void setEventName(){
cout<<"set event name ";
cin>>eventName;
}
};
class EventFunctions:public Events{
public:
void WriteEvent(){
Events obj;
obj.setEventName();
ofstream outf;
outf.open("hello.txt");
outf.write((char *)&obj,sizeof(obj));
outf.close();
}
};
int main(){
EventFunctions ee;
ee.WriteEvent();
}
using devc++
MinGW GCC 11.2.0