Choad
November 29th, 2006, 05:30 AM
bool LoadLevel(std::string filename)
{
std::string line;
std::ifstream levelData(filename.c_str());
int i, o = 0;
char block;
if (levelData.is_open())
{
while (!levelData.eof())
{
std::getline(levelData, line);
block = line[i];
while (!block == NULL)
{
if (block == "1")
{
levelLayout[i][o] = true;
} else
{
levelLayout[i][o] = false;
}
}
o += 1;
}
levelData.close();
} else
{
std::cout << "Unable to open file " << filename << std::endl;
return false;
}
return true;
}
the bit in bold is the code in question...
richard@richard-laptop:~/Desktop$ g++ `sdl-config --cflags --libs` -o maze maze.cpp -lSDL -lSDL_image
maze.cpp: In function ‘bool LoadLevel(std::string)’:
maze.cpp:90: warning: NULL used in arithmetic
maze.cpp:92: error: ISO C++ forbids comparison between pointer and integer
pretty self explanatory really.... i just have no idea lol. any help much appreciated.
{
std::string line;
std::ifstream levelData(filename.c_str());
int i, o = 0;
char block;
if (levelData.is_open())
{
while (!levelData.eof())
{
std::getline(levelData, line);
block = line[i];
while (!block == NULL)
{
if (block == "1")
{
levelLayout[i][o] = true;
} else
{
levelLayout[i][o] = false;
}
}
o += 1;
}
levelData.close();
} else
{
std::cout << "Unable to open file " << filename << std::endl;
return false;
}
return true;
}
the bit in bold is the code in question...
richard@richard-laptop:~/Desktop$ g++ `sdl-config --cflags --libs` -o maze maze.cpp -lSDL -lSDL_image
maze.cpp: In function ‘bool LoadLevel(std::string)’:
maze.cpp:90: warning: NULL used in arithmetic
maze.cpp:92: error: ISO C++ forbids comparison between pointer and integer
pretty self explanatory really.... i just have no idea lol. any help much appreciated.