Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Infinite loop
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples of intentional infinite loops== A simple example (in [[C (programming language)|C]]): <syntaxhighlight lang="c"> #include <stdio.h> int main() { for (;;) // or equivalently, while (1) printf("Infinite Loop\n"); return 0; } </syntaxhighlight> The form <code>for (;;)</code> for an infinite loop is traditional, appearing in the standard reference ''[[The C Programming Language]]'', and is often punningly pronounced "forever".<ref>{{Cite web |url=https://stackoverflow.com/questions/20186809/endless-loop-in-c-c |title=Endless loop in C/C++ |url-status=live |archive-url=https://web.archive.org/web/20160803202212/http://stackoverflow.com/questions/20186809/endless-loop-in-c-c |archive-date=2016-08-03}}</ref> This is a loop that will print "Infinite Loop" without halting. A similar example in 1980s-era [[BASIC programming language|BASIC]]: <syntaxhighlight lang="basic"> 10 PRINT "INFINITE LOOP" 20 GOTO 10 </syntaxhighlight> A similar example in [[MS-DOS]] compatible batch files: <syntaxhighlight lang="bat"> :A echo Infinite Loop goto :A </syntaxhighlight> In [[Java (programming language)|Java]]: <syntaxhighlight lang="java"> while (true) { System.out.println("Infinite Loop"); } </syntaxhighlight> The while loop never terminates because its condition is always true. In [[Bourne Again Shell]]: <syntaxhighlight lang="bash"> for ((;;)); do echo "Infinite Loop" done </syntaxhighlight> In [[Rust (programming language)|Rust]]: <syntaxhighlight lang="rust"> loop { println!("Infinite loop"); } </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Infinite loop
(section)
Add topic