Now here is a problem (with code plz help)
Posted: Wed Jan 11, 2006 7:56 am
class saving
{
f32 a1;
u32 a2;
const wchar_t* a3;
public:
saving()
{a1 = 2.0;a2 = 3;a3 = L"abc";}
void save()
{
a1 = 4;
a2 = 6;
a3 = L"abcde";
IWriteFile *fwrite = device->getFileSystem()->createAndWriteFile("aaa.ini", true);
fwrite->write(reinterpret_cast<char *>(this), sizeof(this));
fwrite->drop();
}
void load()
{
IReadFile *fast = device->getFileSystem()->createAndOpenFile("Optsdion.ini");
fast->read(reinterpret_cast<char *>(this), sizeof(this));
fast->drop();
}
void show()
{
std::cout<<a1<<"\n";
std::cout<<a2<<"\n";
std::wcout<<a3<<"\n";
}}s;
i called upon
s.save(); //for saving object
//s.load()
//s.show()
now when the file wz saved then i used
//s.save()
s.load();
s.show();
here the output screen showed me
4
3
abc
only first value is loaded correctly and the rest two , i don't know why they r not loaded.
r they saved or not plz help and if so why they r not on the output screen as the output should be 4 6 abcde
{
f32 a1;
u32 a2;
const wchar_t* a3;
public:
saving()
{a1 = 2.0;a2 = 3;a3 = L"abc";}
void save()
{
a1 = 4;
a2 = 6;
a3 = L"abcde";
IWriteFile *fwrite = device->getFileSystem()->createAndWriteFile("aaa.ini", true);
fwrite->write(reinterpret_cast<char *>(this), sizeof(this));
fwrite->drop();
}
void load()
{
IReadFile *fast = device->getFileSystem()->createAndOpenFile("Optsdion.ini");
fast->read(reinterpret_cast<char *>(this), sizeof(this));
fast->drop();
}
void show()
{
std::cout<<a1<<"\n";
std::cout<<a2<<"\n";
std::wcout<<a3<<"\n";
}}s;
i called upon
s.save(); //for saving object
//s.load()
//s.show()
now when the file wz saved then i used
//s.save()
s.load();
s.show();
here the output screen showed me
4
3
abc
only first value is loaded correctly and the rest two , i don't know why they r not loaded.
r they saved or not plz help and if so why they r not on the output screen as the output should be 4 6 abcde