I was
> shocked to
> see that the programs could actually be compiled through
> gcc without
> any errors. 

gcc a.c

a.c: In function `main':
a.c:5: error: syntax error before '*' token
a.c:6: error: `s1' undeclared (first use in this function)
a.c:6: error: (Each undeclared identifier is reported only once
a.c:6: error: for each function it appears in.)
a.c:6: error: `s2' undeclared (first use in this function)

$cat a.c
#include <stdio.h>
main()
{

char far *s1,*s2;
printf("%d %d",sizeof(s1),sizeof(s2));

}

http://avsharath.googlepages.com/TestYourCSkillsErrata.htm

Erratum:
1. size of pointer type can vary from implementation to implementation.
2. far is not a standard keyword/type qualifier.
3. sizeof doesn't return integer, it returns a value of type size_t.  So using 
%d will cause undefined behaviour. [This mistake repeats in all the code 
snippets in the book where sizeof value is printed].



_______________________________________________
network mailing list
[email protected]
http://lists.fosscom.in/listinfo.cgi/network-fosscom.in

Reply via email to