Read file block by block

Hi ,

I need to read file block by bock (say of size 2) using ifstream:

void main()
{
std::string line;
std::ifstream myfilessaved;
myfilessaved.open("test.txt");

if (myfilessaved.is_open())
{
while (!myfilessaved.eof())
{
int block = 2;
char * str = new char[block];
myfilessaved.readsome(str, block);
cout << str;
}
}
}

but i am getting some garbage symbols through cout. Could anyone please help me out here..

thanks
Last edited on
Topic archived. No new replies allowed.