Code:#include<stdio.h> #include<conio.h> void main() { char far *s1,*s2; clrscr(); printf("%d %d",sizeof(s1),sizeof(s2)); getch(); }
the output is 4,2 how?
Code:#include<stdio.h> #include<conio.h> void main() { char far *s1,*s2; clrscr(); printf("%d %d",sizeof(s1),sizeof(s2)); getch(); }
the output is 4,2 how?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
There are a few problems with the code (void main, %d for size_t), but "far" is not necessarily one of them. On some systems (OP is almost certainly on MS-DOS; or at least using a 16-bit compiler on an x86), you have different types of pointers due to the underlying architecture. A normal pointer on such a system points into the current segment, and thus is only 16 bits. A far pointer can point to another segment, and so needs to be larger, to hold both which segment it's pointing to and the offset inside of the segment. Thus you have 16-bit "normal" pointers and 32-bit far pointers.