Search Results

Search found 1 results on 1 pages for 'bndu'.

Page 1/1 | 1 

  • Write set of integers to std::ofstream and be able to read them back

    - by bndu
    Hello, I need to write a bunch of unsigned integers to std::ofstream in binary mode: std::ofstream f; f.open("some path", std::ios::out | std::ios::binary); // some loop { unsigned int k = get_k(); // may product numbers from 0 to 65535 f << k; } f.close(); They are written to the output file "as is" w/o any delimiter. So when I'm trying to read them back (expecting to get what I wrote) using std::ifstream I get very strange values. What I'm doing wrong? Or I should to put ' ' (space) to the stream after any added number to separate them? Thanks.

    Read the article

1