0

I know its really simple question, but i cant find answer by myself. I got txt file in this form:

  • 0 0 0 0
  • 1 16 0 1
  • 2 32 0 1
  • 3 48 0 1
  • b 16 16 0

For now i have:

std::ifstream odczyt2;
odczyt2.open("dodatki/textures.txt");
if (odczyt2.is_open())
{
    for (int y = 0; y < 4; y++)
    {
        for (int x = 0; x < 39; x++)
        {
            odczyt2 >> textury[x][y];
        }
    }
}
odczyt2.close();

And i want to make array of chars, which will look exacly the same.

  • It is unclear to me what you want. It looks like you are reading in the file so do you have a problem with that or is your issue with displaying the contents? – NathanOliver Feb 08 '16 at 16:03
  • What you are trying to do is c and there are at least two issues with it: you cannot use `istream::operator>>` to extract to `char *`, and you need to preallocate the memory. The c++ way would be to use a `vector>`... – DarioP Feb 08 '16 at 16:09
  • Is the last line of data correct? It doesn't fit the pattern of the other lines. – Thomas Matthews Feb 08 '16 at 16:10
  • *which will look exacly the same* --- the same as what? – n. m. could be an AI Feb 08 '16 at 16:13

0 Answers0