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

This is for the swing experts out there. I have spent considerable time on
I have found this example on StackOverflow: var people = new List<Person> { new
serial.write() method in pyserial seems to only send string data. I have arrays like
I have spent too much time on this problem and am beginning to think
I have read several articles regarding templates for web site content. They all seem
I have a table with several fields and one field having 3 Comma Separated
I have a Django application being served of (say) example.com . It contains a
I have a UserControl which contains 4 ToggleButtons and I'd like to trigger a
I'd like to subtract two values, one in the current record, then the next
Intro We have a project to design and implement this semester. For our project,

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.