If you are undertaking any embedded software development, it’s crucial that you understand how to write infinite loops. Implementing infinite loops in c++ is actually a piece of cake and I’ll show you three examples that do the job. Keep in mind that infinite loops repeat indefinitely with no terminating condition, so use them wisely.


// While Loop Infinite Loop
while (1)
{

}


// For Lopp Infinite Loop
for (;;)
{
}

</pre>
// Do While Infinite Loop
do
{

}
while (true) 
Share this post

FAQ's

What is an infinite loop in C++?

An infinite loop in C++ is something that makes the program run forever with no terminating condition.

How do you write an infinite loop in C++?

You can find the code here: https://cppbetterexplained.com/infinite-loops-c/

What are the 3 types of loops in C++?

Different types of infinite loops are: While infinite loop, For infinite loop, Do while infinite loop.