473,889 Members | 1,350 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 79849
Richard Heathfield wrote:
Franz Hose said:
>Richard Heathfield wrote:
>>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.
This thing still running?

Yes, although for a week or two it slowed almost to a crawl (the machine
was very busy doing some heavy prime calcs) - but it soon picked up again
afterwards.

I've had to be pretty firm about this program - I've had no fewer than
three (rather generous) offers for exclusive rights to the source code,
one of them from someone in the States who called himself "Mr G", but I
cannot in all conscience release the code, even commercially, until the
test is complete.
I think I know who "Mr G" is. He wants to factor large primes and he
thinks your code might do it. Sell it to him. Also sell him a support
agreement which has you on a monthly retainer to help factor even larger
primes. "G" has money and you have time. Marriage made in heaven.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Dec 15 '07 #51
Richard Heathfield said:
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.
What I was always wondering, in these kind of programs, that never exit,
and never return a value to their hosting environments, what is the best
signature of main()? Consider these possibilities.. .

(1a)
int main(void) {
for(;;) {}
}

(1b)
int main(void) {
for(;;) {}
return 0;
}

(2)
void main(void) {
for(;;) {}
}

1a) most compilers complain about a missing return statement.

1b) some compilers complain about the return statement being unreachable.

2) some compilers complain about void main() (but Schildt uses void main()
a lot in programs that *do* terminate)

Are there any possibilities that compile without warnings?
Dec 15 '07 #52
Fumeur wrote:
Richard Heathfield said:
>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.

What I was always wondering, in these kind of programs, that never exit,
and never return a value to their hosting environments, what is the best
signature of main()? Consider these possibilities.. .

(1a)
int main(void) {
for(;;) {}
}

(1b)
int main(void) {
for(;;) {}
return 0;
}

(2)
void main(void) {
for(;;) {}
}

1a) most compilers complain about a missing return statement.

1b) some compilers complain about the return statement being unreachable.

2) some compilers complain about void main() (but Schildt uses void main()
a lot in programs that *do* terminate)

Are there any possibilities that compile without warnings?

in 1b have you tried putting a label on the return?
Dec 15 '07 #53
On Sun, 16 Dec 2007 00:13:50 +0100, Fumeur <f6@invalid.inv alidwrote:
>Richard Heathfield said:
>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.

What I was always wondering, in these kind of programs, that never exit,
and never return a value to their hosting environments, what is the best
signature of main()? Consider these possibilities.. .

(1a)
int main(void) {
for(;;) {}
}

(1b)
int main(void) {
for(;;) {}
return 0;
}

(2)
void main(void) {
for(;;) {}
}

1a) most compilers complain about a missing return statement.

1b) some compilers complain about the return statement being unreachable.

2) some compilers complain about void main() (but Schildt uses void main()
a lot in programs that *do* terminate)
Just because someone is able to publish a book does not mean the
contents are suitable for the purpose you intend. Betty Crocker
(nowadays I guess it would be Martha Stewart or Wolfgang Puck) would
be a better C reference than Schildt. On the other hand, it is not
completely useless. It contains many examples of what not to do.
>
Are there any possibilities that compile without warnings?
You could try
int i;
for (i = 0; i < 0; i++){
i--;
...
}
Remove del for email
Dec 20 '07 #54
Barry Schwarz said:

<snip>
You could try
int i;
for (i = 0; i < 0; i++){
i--;
...
}
The request was for an infinite loop, but the loop you show here will be
very finite indeed.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 20 '07 #55
RoS
In data Wed, 19 Dec 2007 19:43:16 -0800, Barry Schwarz scrisse:
>>Are there any possibilities that compile without warnings?

You could try
int i;
for (i = 0; i < 0; i++){
i--;
...
}
Remove del for email
the above is not an infinite loop
this will be: for(i=0;i<=0;++ i) --i;
Dec 21 '07 #56
RoS
In data Fri, 21 Dec 2007 08:22:26 +0100, RoS scrisse:
>In data Wed, 19 Dec 2007 19:43:16 -0800, Barry Schwarz scrisse:
>>>Are there any possibilities that compile without warnings?

You could try
int i;
for (i = 0; i < 0; i++){
i--;
...
}
Remove del for email

the above is not an infinite loop
this will be: for(i=0;i<=0;++ i) --i;
nobody have seen there should be an undefinite bheaviour?
(because the start is --i with int i=0)
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.

Dec 23 '07 #57
RoS said:
In data Fri, 21 Dec 2007 08:22:26 +0100, RoS scrisse:
>>In data Wed, 19 Dec 2007 19:43:16 -0800, Barry Schwarz scrisse:
>>>>Are there any possibilities that compile without warnings?

You could try
int i;
for (i = 0; i < 0; i++){
i--;
...
}

the above is not an infinite loop
this will be: for(i=0;i<=0;++ i) --i;

nobody have seen there should be an undefinite bheaviour?
Nobody except you, no.
(because the start is --i with int i=0)
C&V please.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 23 '07 #58
On Wed, 1 Mar 2006 09:03:42 +0000 (UTC), Richard Heathfield wrote:
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.
What are the specifications, specifically,

(1) Under what conditions is the test run considered complete?

(2) Does it maintain some sort of counter? If so,
(2a) How many iterations did it perform already?

(Zed) When the test finally completes, how do you know this loop has run
an infinite number of times?

Jun 27 '08 #59
Two-Horned Unicorn said:
On Wed, 1 Mar 2006 09:03:42 +0000 (UTC), Richard Heathfield wrote:
>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.

What are the specifications, specifically,

(1) Under what conditions is the test run considered complete?
When the loop has run infinitely many times. Anything less would not be a
thorough test.
(2) Does it maintain some sort of counter?
No, no point. I don't have that much storage.
If so,
(2a) How many iterations did it perform already?
See above.
(Zed) When the test finally completes, how do you know this loop has run
an infinite number of times?
I plan to be around to observe the "test complete" message.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #60

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
9807
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,...
0
11188
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10789
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
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
9606
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...
0
5828
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...
0
6028
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
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.