473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how to do an infinite loop

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

Mar 1 '06
59 79640
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.invalidwrote:
>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
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...
5
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
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
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....
44
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 .
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.