Hey i guess its just a simple general coding problem. But i am triding to read in a .txt file. lookin something like this.
00000000000000000000
01111110111111111110
01001010100001000010
01001010111101000010
01111010100101011110
01000010100101010010
01111111111111111010
~~~~~~~~~~~~~~~~~
Where the zero's and ones stand for whether a pac man pellet will be created at its give position. i am having trouble readin it in. This is my code:
char currentChar;
for(int i = 0; i < 20; i ++)
{
for(int j = 0; j < 20; j ++)
{
fMapParam.read(reinterpret_cast<char *>(¤tChar),sizeof(char));
std::cout << currentChar;
}
std::cout << currentChar;
}
std::cout << std::endl;
It prints to the console what would seem to be weird memory addresses. Smilie faces and such thins. Any Ideas?
Thanks
File Input
-
- Posts: 24
- Joined: Fri Oct 28, 2005 10:05 am
- Location: Gold Coast, QLD, Australia
File Input
"do it, do it now"
-
- Posts: 24
- Joined: Fri Oct 28, 2005 10:05 am
- Location: Gold Coast, QLD, Australia
Re: File Input
as always you use my suggestions at your own risk.
but maybe this would work, not very elegant though
but maybe this would work, not very elegant though
Code: Select all
char currentChar[1];
for(int i = 0; i < 20; i ++)
{
for(int j = 0; j < 20; j ++)
{
fMapParam.read(reinterpret_cast<char *>(currentChar),sizeof(char));
std::cout << currentChar;
}
std::cout << currentChar;
}
std::cout << std::endl;