locked
problem with file handling RRS feed

  • Question

  • recently i have started studying file handling and try to make files in my program.

    ofstream fin;


    fin.open(

    "student.txt",ios::out|ios::app);

    it works.however i changed the extension of file name with .ppt and i was successful in making a ppt(not perfectly). but when i tried same thing with .docx and .xlsx. it fails to open in excel and word(2010 edition).it says that file is corrupted.i am confused why it happened?
    Sunday, March 25, 2012 7:39 PM

Answers

  • shwetank verma wrote:

    but when i tried same thing with .docx and .xlsx. it fails to open in  excel and word(2010 edition).it says
    that file is corrupted.i am confused why it happened? 

    I would guess that the data you write to the file is not in the correct  .docx or .xlsx format.


    Igor Tandetnik

    • Marked as answer by lucy-liu Tuesday, April 3, 2012 5:51 AM
    Sunday, March 25, 2012 8:39 PM

All replies

  • shwetank verma wrote:

    but when i tried same thing with .docx and .xlsx. it fails to open in  excel and word(2010 edition).it says
    that file is corrupted.i am confused why it happened? 

    I would guess that the data you write to the file is not in the correct  .docx or .xlsx format.


    Igor Tandetnik

    • Marked as answer by lucy-liu Tuesday, April 3, 2012 5:51 AM
    Sunday, March 25, 2012 8:39 PM
  • >i have started studying file handling and try to make
    >files in my program.

    >i changed the extension of file name ...

    I trust you *do* know that there is a lot more to creating
    a file of a specific type than simply changing the file
    extension? The extension is just a naming convention
    that helps identify what kind of data is in the file.

    A file of the correct format for a given application
    may actually have *any* file extension and still work
    correctly. But a file with invalid data format for a
    given application will never work even with the
    conventional extension.

    Where did you get your information on the internal
    formats for .docx and .xlsx files?

    Note that for working with Word or Excel documents,
    it's usually far easier to use a prewritten API/SDK.

    - Wayne
    Sunday, March 25, 2012 9:12 PM