How to open files that arent txt files?

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?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
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>

using namespace 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:

OpenDocument
http://en.wikipedia.org/wiki/OpenDocument

See the "Standardization" section.

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/)

Andy
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 ......

:)
Topic archived. No new replies allowed.