[FoRK] Re: 2+2=5986

Andy Armstrong < andy at hexten.net > on > Fri Aug 4 09:32:27 PDT 2006

On 4 Aug 2006, at 17:18, Corinna wrote:
> The second one is easy to see. The first one... is it that the %d  
> grabs whatever
> is next in memory, even if you don't provide an argument? That's  
> devious. I'm
> reminded of why I like Java... and perl for that matter.
> :)

Yup, that's exactly right. Although the examples seem quite dated  
(K&R rather than ANSI syntax) and a modern compiler would catch both  
errors . For example

andy at hashbang:~$ cat calc.c
#include <stdio.h>
main() {
     int answer;
     answer = 2 + 2;
     printf("The answer is %d\n");
     return (0);
andy at hashbang:~$ cc -o calc -Wall calc.c
calc.c:2: warning: return type defaults to ‘int’
calc.c: In function ‘main’:
calc.c:5: warning: too few arguments for format

> (disclaimer: yes, I know every language has it's useful sphere. I'm  
> not starting
> a language flame-war :)  )

C's great fun - but a different kind of fun :)

Andy Armstrong, hexten.net

More information about the FoRK mailing list