how to do an infinite loop

M

Markus Wolf

Keith said:
"Are we there yet?"

Maybe you could send me the code in a private message for testing. I've
got a machine here that does the infinite loop in a couple of hours.


-- Mark.
 
U

U

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.
[/QUOTE]

I'm almost afraid to ask... what's the progress?

Regards,
U
 
K

Keith Thompson

U said:
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.

I'm almost afraid to ask... what's the progress?

Regards,
U[/QUOTE]

U! It's you! Where have u been?
 
C

Chris Dollin

Keith said:
U! It's you! Where have u been?

We can now leave all requests like "can u help me ..." to U. That
should reduce the load.

Hmm. Can we find some idiot\\\\\public benefactor to participate here
under the name "You"?
 
P

pete

Chris said:
We can now leave all requests like "can u help me ..." to U. That
should reduce the load.

Hmm. Can we find some idiot\\\\\public benefactor to participate here
under the name "You"?

I used to know a Korean named Yu, and a Chinese guy named Hu.
But I knew them at different times in different places
so I was never able to introduce them to each other: "Hu, Yu. Yu, Hu."
 
R

Richard Heathfield

U said:
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.

I'm almost afraid to ask... what's the progress?[/QUOTE]

In absolute terms, it's extremely encouraging - the loop is proceeding very,
very quickly. But there's a long way to go yet.
Regards,
U

How was your holiday?

(Make sure you're sitting down before you look at the size of your in-tray.)
 
F

Franz Hose

Richard said:
rami said:


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?
 
R

Richard Heathfield

Franz Hose said:
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.
 
R

Richard Tobin

Richard Heathfield said:
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 don't think you need worry. Unless they have *very* fast computers,
their copy won't terminate before yours.

-- Richard
 
J

Joe Wright

Richard said:
Franz Hose said:


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.
 
F

Fumeur

Richard Heathfield said:
rami said:


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?
 
G

Golden California Girls

Fumeur said:
Richard Heathfield said:


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?
 
F

Flash Gordon

Fumeur wrote, On 15/12/07 23:13:
Richard Heathfield said:


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(;;) {}
}
Acceptable.

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

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

Only acceptable if the implementation documents it. Even then, unless it
is freestanding and it specifies 1a/1b as being invalid, why limit yourself?
1a) most compilers complain about a missing return statement.

One warning on a project can be documented as expected and then ignored.
1b) some compilers complain about the return statement being unreachable.

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

If anything, Schildt doing it is an argument *against* doing it. Search
the grou for terms sugh as bullschildt and "bull schildt" for references
to the many errors in his books.
Are there any possibilities that compile without warnings?

Since compilers are allowed to warn about anything they like, no.
However, having worked in a company where there were restrictive coding
standards and the norm was to require clean compilation, I can tell you
that even in such places a *small* number of warnings is generally
acceptable.
 
B

Barry Schwarz

Richard Heathfield said:


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
 
R

Richard Heathfield

Barry Schwarz said:

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.
 
R

RoS

In data Wed, 19 Dec 2007 19:43:16 -0800, Barry Schwarz scrisse:
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;
 
R

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:

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)
 
T

Two-Horned Unicorn

rami said:


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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,087
Latest member
JeremyMedl

Latest Threads

Top