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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:43:06+00:00 2026-06-17T22:43:06+00:00

As in the topic, while I execute the following code .rdstate() returns value 2.

  • 0

As in the topic, while I execute the following code .rdstate() returns value 2. What do I do wrong?

string logger_path_and_name("\"F:\\windowsqnx\\loggs\\logger_file.dat");

/* file to store simulation data */
std::ofstream fout( logger_path_and_name.c_str(), std::ios_base::out | std::ios_base::binary);

/* check if ios::binary supported */
if (!fout.is_open())
{
    std::cerr << "can't create file logger_file.dat\n";
    std::cerr << fout.rdstate();
    system("PAUSE");
    exit(EXIT_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. Editorial Team
    Editorial Team
    2026-06-17T22:43:07+00:00Added an answer on June 17, 2026 at 10:43 pm
    "\"F:\\windowsqnx\\loggs\\logger_file.dat"
    

    Your issue is that this turns into "F:\windowsqnx\loggs\logger_file.dat. As you can see, you have an orphan " at the beginning.

    You can fix this in two ways.
    1. Place another \" at the end.
    2. Remove the \" at the beginning

    On a side note, ios::rdstate returns a Bitmask type and the way you retrieve the information is by using bitwise AND or OR with the iostate flags.

    Example that was shamefully stolen from here:

    // getting state of stream object
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int main () {
      ifstream is;
      is.open ("test.txt");
      if ( (is.rdstate() & ifstream::failbit ) != 0 )
        cerr << "Error opening 'test.txt'\n";
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having the following problem while trying to execute unit tests. I'm working with
I have googled the topic for a while but haven't found what I'm looking
I have been trying to find some resource on this topic for a while
All my questions in this topic related to asp.net 2.0 While working on some
Topic is self explanatory. I found xaml code to do it for an Expander,
While searching for Tutorials on generating random numbers in C I found this topic
I cannot figure out why the following statements dont work. randomKey = random.choice(list(topic.keys())) randomValue
I am getting the following error while browsing my asp.net page deployed in IIS
I have a standardized sequence of code which I used to display topic information
While reading the Hashing topic of C# in a nutshell book,i came across the

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.