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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:57:00+00:00 2026-05-17T14:57:00+00:00

I have spend like one out in this example, and everytime I get the

  • 0

I have spend like one out in this example, and everytime I get the error Unable to read cin with an ios_base::iostate equal to failbit from this code:

#include "dates.h"

#include <iostream>
#include <ctime>
#include <locale>
#include <sstream>
#include <iterator>

using namespace std;

void trasnlateDate(istream&in, ostream&out){
    const time_get<char>& dateReader = use_facet<time_get<char> >(in.getloc());
    ios_base::iostate state = static_cast<ios_base::iostate>(0);
    istreambuf_iterator<char> end;

    tm t;

    dateReader.get_date(in, end, in, state, &t);

    if(state == static_cast<ios_base::iostate>(0) || state == ios_base::eofbit){
        const time_put<char>& dateWriter = use_facet<time_put<char> >(out.getloc());
        char fmt[] = "%x";
        if(dateWriter.put(out, out, out.fill(), &t, &fmt[0], &fmt[2]).failed())
            cerr << "unable to write to output stream.\n";
    }else{
        cerr << "Unable to read cin.\n";
    }
}

int main(){
    locale::global(locale(""));
    cin.imbue(locale("en_US.utf8"));
    cout.imbue(locale("de_DE.utf8"));
    trasnlateDate(cin, cout);
}

as always, gcc 4.4.3 in Ubuntu 10.4 x64

  • 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-05-17T14:57:00+00:00Added an answer on May 17, 2026 at 2:57 pm

    I ran your sample code on a box, and until I entered the input 02/02/2005, it failed just like you said.

    It looks like those leading zeros in month and day fields are necessary.

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

Sidebar

Related Questions

Have spend quite some time to learn Sencha touch, just like an evaluation about
I have always written regexes like this <A HREF=([^]*) TARGET=_blank>([^<]*)</A> but I just learned
I have spent the day researching Android RSS Readers. I would like to parse
I have a feature in my web app like I have to send mails
I have a list of users which I would like to send invite emails
I have a window which is hidden and I would like to send a
I have a table where we record per user values like money_spent, money_spent_on_candy and
I have a byte[] with the contents of file. I would like to send
I would like to have my CI server use a SQS queue to send
I have a scrolling image script that I'd like to update the scroll speed

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.