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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:08:12+00:00 2026-05-18T01:08:12+00:00

i saw an unusual problem in this code: #include <iostream> using namespace std; int

  • 0

i saw an unusual problem in this code:

#include <iostream>
using namespace std;

int main()
{
 int number;
 bool repeat=true;

 while (repeat)
 {
  cout<<"\nEnter a number:";
  cin>>number;
  cout<<"\nNumber is:"
   <<number;
  cout<<"\nRepeat?:";
  cin>>repeat;
 }
 system("pause");
 return 0;
}

here in this code when i put a character such “A” in int type variable while loop repeats over and over and don’t ask me whether to repeat or not.
this problem just appear when i put characters not integers.
this appears with for too.

why should happen this?
thanks

  • 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-18T01:08:13+00:00Added an answer on May 18, 2026 at 1:08 am

    After reading in user input which cannot be converted, the input stream is in an invalid state. You need to empty the stream and call the clear method to reset the error bits on the stream in order to resume normal operation.

    If you detect that input was not successful (using the input streams state bits, accessible via methods like good() or fail() etc.) you can reset the stream using code similar to this:

    std::cin.clear(); 
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Saw this piece of code in a Ruby on Rails book. This first one
Saw this example on the jQuery examples page for Ajax: var xmlDocument = [create
Saw the code here . Can any one tell me what it means? Action
Saw this post at CodeProject for FCKEditor. Can someone explain what about the new
Saw this question recently: Given 2 arrays, the 2nd array containing some of the
Saw that in some example codes, but ive never used it, unless im dynamically
I saw many questions asking 'how' to unit test in a specific language, but
I am implementing URL rewriting in ASP.net and my URLs are causing me a
When I recompiled an old Obj-C project (a Cocoa app), the linker couldn't find
I'm making a SIMPLE, and when I mean simple, I mean simple. But any

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.