473,772 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

for(;0;) printf("hello") ;

for(;0;)
printf("hello") ;

even the condition s wrong i get a hello printed on the screen
y s this happening

Sep 10 '06
51 4149
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgw rote:
>Gv th mn a bnn!
>Give the man a bunny?
Bunion?

-- Richard
Sep 11 '06 #41
Really?
I get nothing.^_^

Sep 11 '06 #42

Spidey wrote:
Thanks for all of your suggestions, and i learned a lot of thing i must
consider before posting a query in any discussion group.

It was my fault, i just typed the code and press (ctrl+f9)
(compile+make+e xecute) and i get that hello in my screen; without
examining anymore i posted the query which was a big mistake;

The code which is executing was not the real one............ ....
sorry, i wont repeat it.
"Never underestimate the power of human stupidity"
Finally u got the lesson, think twice before posting.

Sep 11 '06 #43
Simon Biber <ne**@ralmin.cc wrote:
#include <stdio.h>
int main(void)
{
int arr[5];
printf("%d\n", (int)sizeof arr);
printf("%d\n", (int)sizeof &arr);
return 0;
}
Borland C/C++ 5.5: 20, 20 (wrong)
That is very surprising. I know (from bitter experience) that the
5.4.1 compiler that shipped (AFAIK) with C++ Builder 4 is horribly
bug-ridden, but it seems unforgivable that such an egregious bug was
not fixed in the 5.5 release, free or otherwise.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gma il.com | don't, I need to know. Flames welcome.
Sep 11 '06 #44
"ar******@gmail .com" <ar******@gmail .comwrote:
Really?
I get nothing.^_^
No wonder, if you post without context.

Richard
Sep 11 '06 #45

Spidey wrote:
for(;0;)
printf("hello") ;

even the condition s wrong i get a hello printed on the screen
y s this happening
this could happen if some malicious person went into your stdio.h file
(which you probably included but didnt show) and they added a line
something like: #define for(x).

Either that or the compiler is incorrectly optimizing the code and
somehow falling thru the code the first time.

Sep 11 '06 #46

In article <11************ **********@m79g 2000cwm.googleg roups.com>, "Spiros Bousbouras" <sp****@gmail.c omwrites:
Keith Thompson wrote:
Richard Heathfield <in*****@invali d.invalidwrites :
[...]
Gv th mn a bnn!
Give the man a bunny?

Banana !
And here I was sure it was "bunion".

--
Michael Wojcik mi************@ microfocus.com
Sep 11 '06 #47
Chris Dollin wrote:
jmcgill wrote:
>Brackets are not only proper syntax, they are also a good idea. They
are anything but "clutter."

Opinions differ.

They're certainly proper syntax. Sometimes they are also necessary.
Appendectomies are also sometimes necessary.
Putting braces around statements does not cause you to lose your appendix.
Sep 11 '06 #48
Richard Heathfield wrote:
jmcgill said:
Simon Biber wrote:
for(;0;)
printf("hello") ;
Would it kill you to use curly braces?

Since a parallel reply responds negatively to your suggestion, I thought you
might welcome some support for your position.

Strange as it may seem, not everyone is an expert C programmer. A
maintenance guy in a hurry, confronted with this code:

for(image = 0; image < numimages - 1; image++)
for(y = 0; y < height; y++)
for(x = 0; x < width; x++)
if(img[image].pixel[y][x] & ALPHA)
img[image].pixel[y][x] =
alpha_blend(img[image].pixel[y][x],
img[image + 1].pixel[y][x],
img[image].alpha);

could be forgiven for adding a statement immediately under the alpha_blend
call, on the (incorrect) assumption that it would form part of the inner
loop - and he is especially likely to make this mistake if he has, say, a
Python background.

If the code were like this:

for(image = 0; image < numimages - 1; image++)
{
for(y = 0; y < height; y++)
{
for(x = 0; x < width; x++)
{
if(img[image].pixel[y][x] & ALPHA)
{
img[image].pixel[y][x] =
alpha_blend(img[image].pixel[y][x],
img[image + 1].pixel[y][x],
img[image].alpha);

}
}
}
}

that mistake would be much more difficult to make.

In my opinion, it's a good habit to get into. Obviously, some people's
mileage varies.
Agreed. But I would also like to add that in code like this:

/* ... */
}
}
}
}
}
}

Comments to indicate which block is being closed wouldn't hurt.

Regards,
Bart.

Sep 12 '06 #49
jmcgill wrote:
Chris Dollin wrote:
>jmcgill wrote:
>>Brackets are not only proper syntax, they are also a good idea. They
are anything but "clutter."

Opinions differ.

They're certainly proper syntax. Sometimes they are also necessary.
Appendectomi es are also sometimes necessary.

Putting braces around statements does not cause you to lose your appendix.
Well, that's a relief.

Urm ... and?

--
Chris "don't know where mine is" Dollin
Meaning precedes definition.

Sep 12 '06 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

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.