Jump to content

Never ending For

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
What is the purpose of a never ending FOR loop? I can't think of any reason why I would use it - maybe as a virus to use up resources?

#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Yeah as a virus perhaps? just to make the Pc crash or freeze?

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You could use it in a service that needs to always run a loop to check for something, given you didn't have a timer.

#4
brackett

brackett

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts
Usually, you'd use a while loop for a never ending loop (like for a service). I can't think of any reasonable use for a never ending for loop. Since for loops check a condition and perform an increment (or, in C languages, perform another action) it'd be kind of wasteful to use it in place of a while (true).

#5
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
Hmm, so I guess there really is no use for it...

#6
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
No, there are reasons to use it listed above but they are not very practical.

#7
Ronin

Ronin

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 309 posts
You could also use it in a command line project to always run the main menu loop. That is what we used in class anyway.

#8
Guest_Kaabi_*

Guest_Kaabi_*
  • Guests
The first thing that came to my mind was a virus. But those other uses are better.