"Spidey" <am********@gmail.comwrites:
for(;0;)
printf("hello");
even the condition s wrong i get a hello printed on the screen
y s this happening
Your problem is that you don't yet understand how this newsgroup works.
Please don't use silly abbreviations. This is a technical discusssion
forum, not a chat room. Most of us can guess that "s" means "is" and
"y" means "why", but not everyone here has English as a first
language, and those of us who do have better things to do with our
time than figuring out what your abbreviations mean. (That's what
people have been trying to tell you with responses like
"Y h n p e c.".) If you want our help, take the time to write plain
English. (We won't complain about minor spelling and grammatical
errors.) Proper capitalization and punctuation are also very helpful.
What you *should* have written was something like this:
Even the condition is wrong. I get a "hello" printed on the
screen. Why is this happening?
(The first sentence is still unclear, but at least we can understand
the words.)
If you post a followup, provide context. You need to quote the article
you're replying to, or at least enough of it so that your followup
makes sense to someone who hasn't seen the previous article (but
delete anything that's not relevant to your reply). The Google Groups
interface does this for you. <http://cfaj.freeshell.org/google/has
some good links. See also <http://www.caliburn.nl/topposting.html>.
And see most of the articles in this newsgroup for examples of how
to do it right.
If you post a code sample, don't try to re-type it; copy and paste the
*exact* code that you compiled and executed. We can't tell which
errors were in your original code and which were introduced when you
transcribed it; don't ask us to guess. If at all possible, post a
small complete program that we can try, not just a code fragment.
Very often the actual error is not where you think it is. (If you
knew where the error was, you wouldn't have to ask us.)
I'm going to make a guess about what your problem is. You posted
this:
for(;0;)
printf("hello");
but your program really contains this:
for(;0;);
printf("hello");
The semicolon on the first line indicates a null statement, which is
the statement controlled by the for loop. The printf() call follows
the for loop; it's not part of it. So you do nothing zero times, then
call printf() unconditionally.
(Why would you write "for(;0;)" anyway? There are easier ways to do
nothing.)
Recommended reading:
http://clc-wiki.net/wiki/Introduction_to_comp.lang.c http://www.c-faq.com/
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.