Thread: Input from non-text file

  1. #1
    Registered User starkhorn's Avatar
    Join Date
    Sep 2003
    Posts
    21

    Input from non-text file

    Folks,

    I was just wondering if it was possible to read in data from a non-text file using ifstreams (or indeed any other method) ?

    Basically I've gotten a pdf file and I wish to extract certain parts of data from it. (not graphics, just text).

    I'm guessing that I'd need to do some sort of conversion on the input data in order to be able to read the data correctly ?

    Any ideas would be greatly appreciated.

    Cheers
    STarkhorn

    ps btw, great site and a great resource. I've not posted much simply because I've managed to find most answers to my problems on the FAQ or via the search function.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Just open the file in binary mode and use the stream's get or read member functions to read data into an appropriate sized buffer for further parsing.

    Code:
    ifstream input("whatever.pdf",ios::binary|ios::in);
    char buffer[1000];
    ...
    input.read(buffer,sizeof(buffer));
    ...
    // Now you can parse what's in the buffer
    [edit]If you need to, you can get information on the format of PDF files from wotsit.org which might help.[/edit]
    Last edited by hk_mp5kpdw; 07-29-2004 at 01:21 PM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. fscanf in different functions for the same file
    By bchan90 in forum C Programming
    Replies: 5
    Last Post: 12-03-2008, 09:31 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM