Ok so i want to be able to read a text document that has a different extension like an open office document, it has the extension .odt or something like that. When i try to open it i just get crazy looking characters, so what do i need to do to view the document properly? I wrote this program to display txt documents in the cmd window and it works, bt what will i need to change to get it to view other file types?
/*
Open File is a program that will display the text of any text file
with the extension .txt in the cmd window.
*/
#include <iostream>
#include <string>
#include <fstream>
usingnamespace std;
int main()
{
string fileName;
string storeText;
cout << "What file do you want to open?" << endl;
cout << "The file you want to open must be typed in EXACTLY as it" << endl;
cout << "appears on your computer; for example: document.txt\n" << endl;
getline(cin, fileName);
ifstream fileIn;
fileIn.open(fileName.c_str());
cout << "\n";
if(fileIn.fail())
{
cout << "Failed to open" << endl;
fileIn.close();
}
while(getline(fileIn, storeText))
{
cout << storeText << endl;
}
cin.get();
fileIn.close();
}
Well, if you want to know what the .ODT format is, check out the standards for the Open Document Format, attached as .PDF files to the Wikipedia.org article:
The format is quite involved. To start with, the file can be zipped. So you need to understand how to read zip files (see e.g. zlib - http://www.zlib.net/)
these files cannot be opened in odinary ways .open them in binary mode...
but still they won't work because they were not written in binary mo0de .u'll still receive crazy characters ......