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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:48:57+00:00 2026-06-06T00:48:57+00:00

I’m practicing C++ through Visual C++ Express and tutorials on Youtube. I made a

  • 0

I’m practicing C++ through Visual C++ Express and tutorials on Youtube. I made a calculator by following a cool video, but I didn’t want the program to end right after you do one equation, so I searched for what to do and tried while(true).

The problem is, instead of a number, when the program prompted me to type in a number, I typed in “blah”, hit enter, and the program started to just go crazy so I exited real quick.

Without the while(true), if I type in “blah”, then the program instantly goes to the “press any button to exit…” phrase. So what I’m wondering is, how dangerous is while(true)?
Also, I’m really sorry if this question is inappropriate-_-

  • 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-06T00:48:59+00:00Added an answer on June 6, 2026 at 12:48 am

    while(true) can obviously create an “infinite” loop, which just means there’s nothing internal to the process capable of causing the loop to terminate. It’s still possible that the Operating System may decide (e.g. after a CPU usage quota is exhausted) or be asked (e.g. kill -HUP processid on UNIX/Linux) to terminate the process.

    It’s worth considering the difference between infinite loops containing:

    • blocking (I/O?) requests, such as waits for new network client connections or data or keyboard input, or even just for a specific interval to elapse, then a finite amount of periodic or I/O related processing, and
    • non-blocking branching and data-processing instructions that just spin around burning CPU and/or thrashing CPU/memory caches (e.g. x += array[random(array.size())];)

    The former case may actually be deliberately used in some cases, such as a server process that doesn’t need to do any orderly shutdown and can therefore let the OS shut it down without running any post-loop code, but the second case is usually a programming error: you tend to only have such a while(true) when there’s some way for an exit condition or error occuring during processing controlled by the loop to interrupt the loop. For example, there may be an if (condition) break;, or something that will throw an exception when there’s an error. This may not be obvious – if could for example be an exception from some function that’s invoked – even from having set the Standard iostream’s functions to throw on conversion failure or EOF – rather than a visible throw statement in the source code within the loop.

    It’s worth noting that many other things can create infinite loops too – for example while (a < b) could go forever if there’s no conditions under which a could become >= b. So, it’s a general aspect of programming that you have to consider how your loops exit, and not some problem with the safety of the language. For inputs, it’s normal to do something like:

    while (std::cin >> my_int)
    {
        // can use my_int...
    }
    
    // failed to convert next input from stdin to an int and/or hit EOF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is 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.