The two top numbers are MapWidth/MapHeight. I've used to pass them as arguments in functions, but it's inconvenient now. So how can I save those two numbers separately using fscanf()? How can I tell it to stop after the first number and store the second number in the second integer variable?
(Btw: The '00:0' is the map which is already loaded correctly by using the FILE* structure and fscanf while Looping through)
I don't use the c++ style cauz I don't know how >.< How can I load the map which has the Format TileID:TypeID with your way? Loading simple words is easy, but I can't apply that on some more diffculte formats...
#include <fstream>
#include <iostream>
int main()
{
std::ifstream file("file.txt"); // your filename
int width;
int height;
if(file.is_open())
{
file >> width;
file >> height;
std::cout << "width: " << width << "\nheight: " << height << std::endl;
int tile;
int type;
// for all tiles
while(file >> tile) // if there is one more tile
{
// ignore the next character
file.ignore(1);
// get type
file >> type;
// do something with tile and type
std::cout << "tile: " << tile << "\ntype: " << type << std::endl;
}
}
return 0;
}