A
Andrew
Helo Everyone. Im in need of some help with a C++ method. I am trying
to read entries from a MyData.dat file, and enter each of those
entries into an array.
MyArray was properly declared and MyFile was decalred as type
ifstream. I have also tried declaring it as type ofstream, both
without success. The code I have tried so far is:
int Index;
For (Index = 0; Index <10; Index = Index +1)
{
MyFile.open("MyData.dat")
MyFile<<MyArray[Index].Number<<endl;
MyFile.close("MyData.dat);
}
and
int Index;
For (Index = 0; Index <10; Index = Index +1)
{
MyFile.open("MyData.dat")
MyFile>>MyArray[Index].Number>>endl;
MyFile.close("MyData.dat);
}
In both cases, on checking the values of MyArray[Index], I get some
figures which are not the same as those contained in MyData file. Can
anyone please help me?
Andrew.
to read entries from a MyData.dat file, and enter each of those
entries into an array.
MyArray was properly declared and MyFile was decalred as type
ifstream. I have also tried declaring it as type ofstream, both
without success. The code I have tried so far is:
int Index;
For (Index = 0; Index <10; Index = Index +1)
{
MyFile.open("MyData.dat")
MyFile<<MyArray[Index].Number<<endl;
MyFile.close("MyData.dat);
}
and
int Index;
For (Index = 0; Index <10; Index = Index +1)
{
MyFile.open("MyData.dat")
MyFile>>MyArray[Index].Number>>endl;
MyFile.close("MyData.dat);
}
In both cases, on checking the values of MyArray[Index], I get some
figures which are not the same as those contained in MyData file. Can
anyone please help me?
Andrew.