Answer the question
In order to leave comments, you need to log in
Why is the array incorrectly filled from the file?
Having an array in the file:
33 99 0 1 3 7
1 9 77 0 2 1
when opening a stream and filling an array from it, I have an array consisting of -842150451 of this kind of numbers
I wrote a code for sorting, when entering an array from the keyboard, everything works, read from the file doesn’t want to, I can’t understand what the problem is, as I did it according to the manual (I did a check for opening the stream, the file path is correct)
ifstream in("D:\\files\\firstfile.txt");
ofstream out("D:\\files\\secondfile.txt");
int **Create(ifstream& in, int Length, int Higth)
{
int **Mass = new int*[Higth];
for (int i = 0; i < Higth; ++i)
{
Mass[i] = new int[Length];
}
for (int i = 0; i < Higth; ++i)
{
for (int j = 0; j < Length; ++j)
{
in >> Mass[i][j];
}
}
in.close();
return Mass;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question