K
kenny
i want to write infinite loop
1. can do in c language ?
2. how is useful ?
1. can do in c language ?
2. how is useful ?
kenny said:i want to write infinite loop
1. can do in c language ?
2. how is useful ?
kenny said:i want to write infinite loop
1. can do in c language ?
2. how is useful ?
kenny said:i want to write infinite loop
kenny said:i want to write infinite loop
1. can do in c language ?
2. how is useful ?
kenny said:i want to write infinite loop ....
2. how is useful ?
i want to write infinite loop
1. can do in c language ?
2. how is useful ?
Golden California Girls said:Rather than while (1) {} which I agree can cause questions for later maintainers
of the code I have seen while (hell_freezes_over) {} to make it obvious the
author intends it to be infinite. I even seen the do {} while
(hell_freezes_over) form.
Golden California Girls said:Rather than while (1) {} which I agree can cause questions for later
maintainers of the code I have seen while (hell_freezes_over) {} to
make it obvious the author intends it to be infinite. I even seen
the do {} while (hell_freezes_over) form.
[etc.]Nate Eldredge said:while (A_THING_OF_BEAUTY_IS_A_JOY) { }
while (1) {} /* one way */
do {} while(1); /* another way */
for (; {} /* a third way */
foo: goto foo; /* a fourth way */
karthikbalaguru said:
Imagine that you are a craftsman in a workshop that contains many
tools. Someone comes in and asks you how many different ways you
can think of to insert a woodscrew into an offcut.
First, you demonstrate how to do this with a manual screwdriver.
Then you do the same thing, this time with an electric screwdriver.
Then you show that it can be done with a hammer, too, albeit not
quite so neatly.
Fourthly, you cut a small recess in the wood with a hammer and
chisel and place a screw into the recess.
Fifthly, you drill a hole wider than the screw and drop the screw
into the hole. (Again, you can do this both manually and
electrically.)
You may be able to think of some other ways to do this, too.
But, says your visitor, WHY does carpentry provide so many ways to
do this?
That's the wrong question - partly because it makes little if any
difference, and partly because the answer would vary from machine
to machine,
karthikbalaguru said:
Imagine that you are a craftsman in a workshop that contains many
tools. Someone comes in and asks you how many different ways you
can think of to insert a woodscrew into an offcut.
First, you demonstrate how to do this with a manual screwdriver.
Then you do the same thing, this time with an electric screwdriver.
Then you show that it can be done with a hammer, too, albeit not
quite so neatly.
Fourthly, you cut a small recess in the wood with a hammer and
chisel and place a screw into the recess.
Fifthly, you drill a hole wider than the screw and drop the screw
into the hole. (Again, you can do this both manually and
electrically.)
You may be able to think of some other ways to do this, too.
But, says your visitor, WHY does carpentry provide so many ways to
do this?
That's the wrong question - partly because it makes little if any
difference, and partly because the answer would vary from machine
to machine,
karthikbalaguru said:
karthikbalaguru said:Which one of the above methods [of programming an infinite
loop] consume less cycles ?
That's the wrong question - partly because it makes little if any
difference, and partly because the answer would vary from machine
to machine,Considering a x86 machine, which one will be faster (Less Cycles)
? Any ideas ?
It's still the wrong question.
Consider this: either the loop body will be doing a lot of work (in
which case the tiny cost of looping, *however* you do it, will be
insignificant), or the loop body will not be doing a lot of work
(in which case the overhead doesn't matter anyway, because there's
plenty of capacity).
karthikbalaguru said:But, why does C provide some many
ways of infinite loop ?
Which one of the above methods consume
less cycles ?
Considering a x86 machine, which one will be faster (Less Cycles) ?
and Which one will consume more memory ?
Any ideas ?
karthikbalaguru said:But, why does C provide some many
ways of infinite loop ?
Which one of the above methods consume
less cycles ?
karthikbalaguru said:But, i am really interested to know considering
the loop body does not do anything. (It is just an infinite loop
without body.)
I am intested to know this because various forms of
programming an infinite loop is supported .
Also, are there any specific scenarios in which
those methods should be used ?
Any ideas ?
Considering a x86 machine, which one will be faster (Less Cycles) ?
Any ideas ?
Thx in advans,
Karthik Balaguru
karthikbalaguru said:But, why does C provide some many
ways of infinite loop ?
Which one of the above methods consume
less cycles ?
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.