   File IO in C++
  Hello, I need help with file IO, I want to write be able to write an array to a file, aswell as being able to read that same array from a file.Any one know how to do this?   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document
  the only thing that actually comes to my mind is to write the eacharray separated by comma, but it''s too complicated. forget it!  ;  no that wouldn''t work, since its an array of classes. Which I''m trying to read and write.   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document ;  You can use binary files let's say you have an array...int array[20]; ..Now you have all the information set up etc and you save it like thisFILE *f =fopen("file.dat","wb");fwrite(&array,sizeof(array),1,f);fclose(f);When you want to load it just do this...FILE *f = fopen("file.dat","rb");fread(&array,sizeof(array),1,f);fclose(f); [edited by - FtMonkey on August 4, 2003 8:59:01 PM];  You can do either text or binary IO.   For text, the C++ fstream library is probably easier (fstream not fstream.h, the .h''s are the old headers for C++).  For binary IO, the C routines are easier to learn how to use - fopen, fread, fwrite, & fclose. ;  I knew nothing about the fstream class, but this reference page helped me enough to write a model loader from scratch. http://www.cplusplus.com/ref/iostream/fstream/ ;  Also if you''re dealing with pointers, like inside your class for instance, do a search for serialization if you''re planning to save it in binary.   --{You fight like a dairy farmer!} ;  I''ve gotten working thanks for everyone help.   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document 