Original Post
Hi, i have a problem with file i/o. I need to read a file twice (cause of memory allocation) but i can't set the file Pointer to the beginning of the file after reading it. It always replies a EOF. The programm should convert a Wavefront OBJ file to my own file format. I tried the following things (everything is simplified): The only thing that worked was that i created a new ifstream like for example obj_file2 and read the same file again, but thats somehow stupid and in some casesnot practical (when you need to read lots of files). I think i overloocked something really simple, but i dont get it. Thanks for your help!
//startup
ifstream obj_file(argv[1]);
obj_file.getline(obj_line, 256);
while(!obj_file.eof())
{
//read and count things
obj_file.getline(obj_line, 256);
}
//allocate memory
//obj_file.seekg(0, ios::beg); //does not work (still eof)
obj_file.seekg((streampos)0); //does not work (still eof)
/*
obj_file.close();
obj_file.open(argv[1], ios::in); //does not work (still eof)
*/