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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:40:41+00:00 2026-06-06T11:40:41+00:00

This problem has been bugging me for a long time. For example, the code

  • 0

This problem has been bugging me for a long time. For example, the code

ifstream in;
char temp;
int a;

in.open ("Random.txt");

for (a = 0;a < 10000;a++)
    in.read (&temp, 1);

in.close ();

works fine until the ifstream encounters a substitute character (ASCII = 26). Then, for all following characters, ifstream::read gives me temp = -1. I don’t really want this to happen, but instead want it to keep on reading characters from the file instead of -1. What have I done wrong?

  • 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-06T11:40:44+00:00Added an answer on June 6, 2026 at 11:40 am

    You need to open the stream in binary mode. For historic reasons the text mode on Windows will consider Control-Z (ASCII 26) as the end of a file.

    There are more details in this earlier answer of mine.

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

Sidebar

Related Questions

This has been bugging me for some time now. My problem is the following.
This Jquery problem has been bugging me for a while now. I developed a
This problem has been bugging me for a while. I have to load a
This has been bugging me for about 4 hours, so I thought it's time
This problem has been bugging me for the last week or so and now
There's this problem that has been bugging me all day now, and I hoped
This problem has been bugging me since forever. I have an array and in
This problem has been bugging me for hours already. I am deploying a Rails3
This problem has been bugging me for a while now. I have a created
This has been bugging me for some time now, as a newbie I'm not

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.