473,889 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to do an infinite loop

please everybody ,can anyone tell me how to do an infinite loop in C

Mar 1 '06
59 79847

"Keith Thompson" wrote:
"John F" <sp**@127.0.0.1 > writes:
"Guillaume" wrote:
William J. Leary Jr. wrote:
#define ever ;;

for (ever)
{
/* We're in here forever */
}
<SNIP>
A 'for'
loop without two visible ';' is a syntax mess. Don't do it.
#define ever

for (;ever;)
{
/*code to do*/
}

better?


No.


I just wanted to be a little bit sarcastic.
If someone reading your code knows C, he knows perfectly well what
"for (;;)" means; he'll have no idea what "ever" means without looking
it up. If he doesn't know C, no amount of preprocessor trickery will
let him understand the code; rather, it will prevent him from learning
good C.
Depends on whether he needs to learn it... Some bosses strictly refuse to
learn anything...
(I don't think you meant to imply that it *is* better, so take this as
an expansion on what you wrote, not a criticism.)
I just wanted to point out, that present ";;" don't necessarily imply
readability/maintainability ... It can still be very ambiguous, as you have
pointed out correctly:
Note that a sufficiently malicious programmer could do something like
this:

#define ever 0

for (;ever;) {
/* this is never executed */
}


This would be extremely bad. Indeed. "never" would be a better name
(although the method is generally an abuse of the preprocessor ...)

#define LOOP_NEXT_BLOCK _FOREVER for(;;)

would be just as bad...

I usually do something like

/*infinit loop intentionally*/
for(;;)
{ /*short explaination of the purpose + why infinit*/

/*code goes here*/

}/*~for(;;)*/

all that, just to make things clear for later reading (in case my boss wants
to see what we are doing...)
(I even know people who just wrote for(;;) and intended to fill the missing
parts later on, but then again forgot to do so some lines later... I don't
know how they could get a programmers job, actually)

--
regards
John
Mar 3 '06 #31
John F said:
(I even know people who just wrote for(;;) and intended to fill the
missing parts later on, but then again forgot to do so some lines later...


For the record, my infinite loop program is still going strong (that's two
days now, I think), but the test so far has been inconclusive.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Mar 3 '06 #32

"Richard Heathfield" <in*****@invali d.invalid> wrote in message
news:du******** **@nwrdmz02.dmz .ncs.ea.ibs-infra.bt.com...
-snip

For the record, my infinite loop program is still going strong (that's two
days now, I think), but the test so far has been inconclusive.


Better hope the power doesn't go out!

--
MrG{DRGN}
Mar 3 '06 #33
MrG{DRGN} said:

"Richard Heathfield" <in*****@invali d.invalid> wrote in message
news:du******** **@nwrdmz02.dmz .ncs.ea.ibs-infra.bt.com...
-snip

For the record, my infinite loop program is still going strong (that's
two days now, I think), but the test so far has been inconclusive.


Better hope the power doesn't go out!


Well, that's what UPS is for. It's uninterruptible , right?

The food might run out. The oceans might dry up. The human race might die
out completely. The sun might bloat out into space and consume the earth in
a fiery death. The combined mass of the entire universe might reach its
expansion limit and then coalesce into the mother of all black holes.

But my UPS will still be supplying power to my PC, because that's what
"uninterruptibl e" means. And my PC must also somehow survive all this,
because it's running an *infinite* loop.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Mar 4 '06 #34
Richard Heathfield ha scritto:

...

Well, that's what UPS is for. It's uninterruptible , right?

The food might run out. The oceans might dry up. The human race might die
out completely. The sun might bloat out into space and consume the earth in
a fiery death. The combined mass of the entire universe might reach its
expansion limit and then coalesce into the mother of all black holes.

But my UPS will still be supplying power to my PC, because that's what
"uninterruptibl e" means. And my PC must also somehow survive all this,
because it's running an *infinite* loop.


*lol*!
So you solved one of the greatest misteries of the human kind: computers
will survive men, definitely. As there will always be at least one
computer on Earth that is running an infinite loop. Computers will get
their power from us. We will become computers' power suppliers.
Something like Matrix. :)

David

--
Linux Registered User #334216
Get FireFox! >> http://www.spreadfirefox.com/?q=affiliates&id=48183&t=1
Staff >> http://www.debianizzati.org <<
Mar 4 '06 #35
Richard Heathfield wrote:
John F said:
(I even know people who just wrote for(;;) and intended to fill the
missing parts later on, but then again forgot to do so some lines later...


For the record, my infinite loop program is still going strong (that's two
days now, I think), but the test so far has been inconclusive.


Now if you can just arrange to extract a few ergs net from each
pass, we could be well on the way to energy independence.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
Mar 4 '06 #36
Richard Heathfield wrote:
MrG{DRGN} said:
"Richard Heathfield" <in*****@invali d.invalid> wrote in message
news:du******** **@nwrdmz02.dmz .ncs.ea.ibs-infra.bt.com...
-snip
For the record, my infinite loop program is still going strong (that's
two days now, I think), but the test so far has been inconclusive.

Better hope the power doesn't go out!


Well, that's what UPS is for. It's uninterruptible , right?

The food might run out. The oceans might dry up. The human race might die
out completely. The sun might bloat out into space and consume the earth in
a fiery death. The combined mass of the entire universe might reach its
expansion limit and then coalesce into the mother of all black holes.

But my UPS will still be supplying power to my PC, because that's what
"uninterruptibl e" means. And my PC must also somehow survive all this,
because it's running an *infinite* loop.


That was great! I needed that laugh...Thank you!

--
Sean
Mar 10 '06 #37
On Wed, 1 Mar 2006 09:03:42 +0000 (UTC),
Richard Heathfield <in*****@invali d.invalidwrote:
rami said:
>please everybody ,can anyone tell me how to do an infinite loop in C

I have written a program for you, that contains an infinite loop, but it
wouldn't be right to show you the code until its test run is complete.
Richard,

I'd be very interested to see that code too, so... what's the status? Is
it anywhere near infinity yet?

Many thanks in advance.

--
mwo, Researcher

Jul 16 '06 #38
Man with Oscilloscope said:

<snip>
>
I'd be very interested to see that code too, so... what's the status? Is
it anywhere near infinity yet?
137 days later... it's still going strong, but there's some way to go yet.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 16 '06 #39
Richard Heathfield <in*****@invali d.invalidwrites :
Man with Oscilloscope said:

<snip>
>>
I'd be very interested to see that code too, so... what's the status? Is
it anywhere near infinity yet?

137 days later... it's still going strong, but there's some way to go yet.
"Are we there yet?"

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 16 '06 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
5620
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a fallacy built on the assumption of mythical infinite all powerfull machines. In reality we deal with finite machines that are capable of two states in a loop, they either terminate, or repeat themselves. In the mythical halting problem scenario...
5
4957
by: mailpitches | last post by:
Hello, Is there any way to kill a Javascript infinite loop in Safari without force-quitting the browser? MP
4
2644
by: LOPEZ GARCIA DE LOMANA, ADRIAN | last post by:
Hi all, I have a question with some code I'm writting: def main(): if option == 1: function_a()
10
7664
by: Steven Woody | last post by:
i have a program which always run dead after one or two days, i think somewhere a piece of the code is suspicious of involving into a infinite loop. but for some reason, it is very hard to debug. so i thing there might be tool which can statically analysis the code and notice me this kind of potential problems if found. any suggestion? ( i prefer linux open source tools ) thanks. -
44
4320
by: James Watt | last post by:
can anyone tell me how to do an infinite loop in C/C++, please ? this is not a homework question .
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9805
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9603
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4249
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.