How to read this type of text file using C/C++?

Discussion in 'C++' started by imagine2200, Jul 6, 2009.

  1. imagine2200

    imagine2200 New Member

    Joined:
    Apr 14, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    hej everyone,

    I opened MS word file in NOTEPAD and saved it as text file so that i can read the saved file using C/C++ streams. Below i have given image of MS word file opened in NOTEPAD and then i tried to read it using C/C++ streams but my programs reads the first few characters and then terminates. Why can't i read all these characters?

    Any help in this regard will be appreciated.

    Thanks
     
  2. imagine2200

    imagine2200 New Member

    Joined:
    Apr 14, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    [​IMG]

    remove the spaces.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Spaces removed and you have messed up with your doc file and try renaming the file into doc file and see if it works.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    You can only read such files in binary mode. MS Word documents are not stored as text files.

    Without code I can only guess why your program exits. Perhaps it quits at the first occurrence of a certain byte value, e.g. 0x00 or 0xFF. Maybe it crashes due to expecting text and getting binary.

    Do you know how to decode MS Word documents?
     
  5. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Are you people using VC++ ?
     
  6. imagine2200

    imagine2200 New Member

    Joined:
    Apr 14, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    @xpi0t0s

    -

    Nopes, i think that require knowledge of OLE and office automation.
     
  7. imagine2200

    imagine2200 New Member

    Joined:
    Apr 14, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    @naimish

    -

    I am using Dev-C++ IDE.
     
  8. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Yeah...me 2 :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice