Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:34:42+00:00 2026-06-12T23:34:42+00:00

A bad way to store bytes: I stored about some bytes in a file.

  • 0

A bad way to store bytes:
I stored about some bytes in a file. The bytes were made up of arbitrary bits( 1 or 0).
About ten bytes form a log item. I add a ‘\n’ at the end of the log.
Later when I read from the file(the file was stored and read both in Text format).
I found some two bytes of the log make up a ‘\n'(0x0d,0x0a).
But I use ‘readLine()‘ of the stream of the file to read contents of the file, which failed to recognize the correct end of a line obviously.
What I got turned out to be a mass, but is there a better way to store the bytes(containing arbitrary 1 or 0) and read from the file?
I use c++ in qt, a solution under the IDE should be better if possible.

My English is poor. Thank for your patience to read!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:34:43+00:00Added an answer on June 12, 2026 at 11:34 pm

    I suspect you are using windows and you’re writing in text mode and reading in binary mode.

    On windows text files that are saved to the filesystem should have \r\n (0x0d,0x0a) at the end of the line. Writing in text mode automatically adds the \r when ever there is a \n. Reading in text mode will remove the \r so you should never see it.

    If you read and write in the same mode (text or binary) then you will see the same data as you wrote. On linux there in no difference between text mode and binary mode but you should get the mode right to keep your code portable..

    If this is a binary file (sounds like you’re writing bytes rather than strings) then you should probably use binary mode for both reading and writing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to parse a large floating point file stored in
Some co-workers and I got into a debate on the best way to store
I am looking for a optimal way to store info about which users already
My superior once told me that a bad way of calling a web service
I know I'm doing this a bad way... but I'm having trouble seeing any
Apparently, using AttachDbFilename and user instance in your connection string is a bad way
What bad things happen at the moment document.write() is invoked? I've heard bits and
I'm new to PHP and SQL, but I need a way to store the
Building a relatively simple website, and need to store some data in the database
I don’t have much experience with python but I’d like a way to store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.