Thread: Binary files read newline (help)

  1. #1

    Cool Binary files read newline (help)

    I have a binary file which contains two numbers


    both number are separated with a newline.

    When I read it back in to retieve the data I cannot get my orignal data back, I get a strange number.
    Please help.,4);


    y = (double *) &buffer[0];,4);
    z = *y;

    unsigned int x = (unsigned int)floor(z);
    cout << z <<"|"<< x << endl;


  2. #2
    Registered User
    Join Date
    Nov 2002
    If that is an example of the data your binary file has, then it is not a binary file in the sense that that data is not the binary represenation of those numbers. If your numbers are seperated by a new line, why not simply do infile >> mynumber; in a loop until you hit EOF?

  3. #3


    Sorry I meant the binary file generated contains those numbers, but when you look at the file it is garbage characters like i.e.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-02-2008, 12:33 PM
  2. "sorting news" assignment
    By prljavibluzer in forum C Programming
    Replies: 7
    Last Post: 02-06-2008, 06:45 AM
  3. Merge Binary Files
    By chinook86 in forum C Programming
    Replies: 7
    Last Post: 01-21-2008, 02:19 PM
  4. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  5. Binary files
    By Lionmane in forum C Programming
    Replies: 35
    Last Post: 08-25-2005, 01:56 PM