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

  • Home
  • SEARCH
  • 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
  • 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. 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

Ask A Question

Stats

  • Questions 96k
  • Answers 97k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The best way is to use it! Write a simple… May 11, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer Which version of silverlight do you use? <extendedProtectionPolicy> is available… May 11, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer From C# 6 onwards, you can just use: MyEvent?.Invoke(); or:… May 11, 2026 at 7:18 pm

Related Questions

I imagine this is a pretty hard question to answer without sitting down and
OK, I have been working on a random image selector and queue system (so
We use Guids as primary keys for entities in the database. Traditionally, we've followed
I'm trying to find the most reusable, yet elegant, piece of code possible for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.