K
Keith Willis
int main(void) {
while(1);
return (0);
}
#define HELL_NOT_FROZEN_OVER (1)
..
..
..
while(HELL_NOT_FROZEN_OVER)
{
do_stuff();
}
..
..
..
int main(void) {
while(1);
return (0);
}
A better question is "why do an infinite loop?". Loops that are
deliberately written to be infinite are rare; ones where it was a good
idea are even rarer. Why do you want to do this?
Main loop in event-driven approach?
It would probably have some break statement to exit the loop
when some particular event happens, but it would still be an
infinite loop ;-)
Well, it's a debate that resembles the one about the use of
goto statements.
I wouldn't say that they shouldn't be used, no matter what.
Both goto statements and infinite loops, when typed in with
the fingers connected to the brain, in some cases could lead
to better code quality (read: clarity) than any other
construct providing the same functionality.
Martin said:There being no such language as C/C++,
it is impossible to do anything
with it.
In either C or C++, a simple statement like
while(1) ;
produces an infinite loop.
Certainly not; no teacher would be braindead enough to assign it.
A better question is "why do an infinite loop?". Loops that are
deliberately written to be infinite are rare; ones where it was a good
idea are even rarer. Why do you want to do this?
Martin said:There being no such language as C/C++, it is impossible to do anything
with it.
In either C or C++, a simple statement like
while(1) ;
produces an infinite loop.
Certainly not; no teacher would be braindead enough to assign it.
James said:Martin said:There being no such language as C/C++, it is impossible to do anything
with it.
Actually, this came up in a job offer that explicitly listed, and I
quote
...experience in C/C++ [is] an advantage, but not a requirement...
Are you saying there is no such thing?
[...]James said:Martin said:There being no such language as C/C++, it is impossible to do anything
with it.
Actually, this came up in a job offer that explicitly listed, and I
quote
...experience in C/C++ [is] an advantage, but not a requirement...
Are you saying there is no such thing?
James said:Actually, this came up in a job offer that explicitly listed, and I
quote
...experience in C/C++ [is] an advantage, but not a requirement...
Are you saying there is no such thing?[...]
Correct, there is no such language as "C/C++". C and C++ are two
distinct (but closely related) languages.
People often use the term "C/C++" as if it were the name of a language.
The charitable interpretation of this is that it really means "C and
C++", or "C or C++", or "C and/or C++".
Or perhaps "C || C++", which means that if C is good enough,
you don't need to go on to C++. }
Keith said:[...]James said:Martin said:James Watt wrote:
can anyone tell me how to do an infinite loop in C/C++, please ?
There being no such language as C/C++, it is impossible to do anything
with it.
Actually, this came up in a job offer that explicitly listed, and I quote
...experience in C/C++ [is] an advantage, but not a requirement...
Are you saying there is no such thing?
Correct, there is no such language as "C/C++". C and C++ are two
distinct (but closely related) languages.
People often use the term "C/C++" as if it were the name of a language.
The charitable interpretation of this is that it really means "C and
C++", or "C or C++", or "C and/or C++".
Or perhaps "C || C++", which means that if C is good enough, you don't
need to go on to C++. }
Keith said:[...]James said:Martin said:James Watt wrote:
can anyone tell me how to do an infinite loop in C/C++, please ?
There being no such language as C/C++,
it is impossible to do anything with it.
Actually, this came up in a job offer that explicitly listed, and I
quote
...experience in C/C++ [is] an advantage,
but not a requirement...
Are you saying there is no such thing?
Correct, there is no such language as "C/C++". C and C++ are two
distinct (but closely related) languages.
People often use the term "C/C++"
as if it were the name of a language.
The charitable interpretation of this is that it really means "C and
C++", or "C or C++", or "C and/or C++".
There's a newsgroup for learning it:
news:alt.comp.lang.learn.c-c++
Richard said:pete said:
That's not for C/C++, but for C-C++.
To prevent my OS-less microcontroller based gizmo's main() from
returning.
Dan Henry said:
Yes, that is the only reasonable use I can think of for an infinite loop -
"we're gonna keep doing this as long as power remains, and we have no way
of knowing how long that will be..."
Richard Heathfield wrote, On 18/11/07 00:13:
Or we are going to keep this daemon/TSR/whatever running until it
receives-a-SIGINT/is-given-some-implementation-specific-signal-telling-
it-to-terminate/is-killed-by-the-OS.
James said:Martin said:There being no such language as C/C++, it is impossible to do anything
with it.
Actually, this came up in a job offer that explicitly listed, and I
quote
...experience in C/C++ [is] an advantage, but not a requirement...
Are you saying there is no such thing?
My guess would be they want applicants debate advantages/disadvantages
of the various possible control structures (are there any?), but not
being a programmer I can only guess.
My experience tells me some teachers are.
Miguel said:When you are programming a microcontroller or DSP you'll need usually an
infinite loop.
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.