On 26/11/10 21:48, Tobias Fröschle wrote:

> main(){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}}
Error!

Puts() needs #include <stdio.h> or at least defining correctly!
Main() always returns int.
Main always takes two parameters int and char **.
Your main() function doesn't return a value.

The correct (?) version would then be something like:

#include <stdio.h>
int main(int argc, char
**argv){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}return 0;}

Slightly longer now and I still haven't #included the header for puts()
to work correctly.

Plus, do we count the bytes in stdio.h as part of the program? I rather
suspect we should.

Reducing it to the minimum would be:


int puts(s)
char *s;
int main(int c, char
**v){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}return 0;}

or

int puts(char *s);
int main(int c, char
**v){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}return 0;}

:-)


> And is of course way more readable, structured, object-oriented and
> modern as well.....
Indeed! ;-)


Cheers,
Norman.

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to