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 57859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:45:26+00:00 2026-05-10T17:45:26+00:00

I knew I should never have started using c++ io, the whole type safety

  • 0

I knew I should never have started using c++ io, the whole ‘type safety’ argument is a red herring (does anyone really find that it’s one of their most pressing problems?). Anyhow, I did, and discovered a strange difference between ifstreams and FILE*s and plain old file descriptors: ifstreams cannot read from a device. Can anyone think of a reason why?

const char* path = '/dev/disk3'; char        b;  // this works FILE* f= fopen(path, 'rb'); int i = fread(&b, 1, 1, f);     // returns 1, success!  // this does not work ifstream    cf(path, ios::binary); cf.read(&b, 1); bool        good = cf.good();   // returns false, failure. 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T17:45:26+00:00Added an answer on May 10, 2026 at 5:45 pm

    The device is unbuffered and must be read from in 512 byte multiples. ifstream does it’s own buffering and strangely decided to read 1023 bytes ahead, which fails with ‘Invalid argument’. Interestingly, this ifstream is implemented on top of a FILE*. However, FILE* left to its own devices was reading ahead using a nicer, rounder number of bytes.

    Thanks to dtrace for vital clues. I guess we’ll never know if the folk who thought they knew answer but didn’t want to say were right.

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

Sidebar

Related Questions

I knew that when we allocate memory by using new/new[], then we should release
I was wondering if anyone knew of a way to recolor an image using
I knew ORM tools, such as Hibernate, have their own transaction management mechanism. We
I was wondering if anyone knew of a way to do some client side
I was wondering if anyone knew whether taskmgr.exe in Windows Vista/7 was extend-able via
I was wondering if anyone knew how iSimulate automatically registers/hooks itself into a debugged
I was wondering if anyone knew a good way of creating an AS3 Facebook
I have never used unit testing before, so I'm giving CxxTest a go. I
I have this ant script which should create the table customer. I see the
I have lots of objects. I should evaluate one of thier members.them one by

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.