Search code examples
c++inputfile-ioinputstream.doc

Does fin in C++ work with .doc files?


I used fin to read in a .doc file, and then store all the text in a string. When I tried printing the string, I just saw unknown characters.

When I copied the contents of the .doc file into a .txt file and then read the .txt file in using fin, everything worked fine.

My question is whether fin works with complex files (such as .doc) or just with .txt files. I only had text in my .doc file (no graphics or anything), but the font was Calibri, which is not the font that fout uses to print text to a .doc file.


Solution

  • If by fin you mean an fistream yes it will work to read the file contents, however in the case of complex files you have to deal with the file format, the c++ library will not automatically extract just the text contents. In the case where you saved the file as text that's all that is left and so that's all a stream would read.