A
amit khan
Hello friends,
I have a couple of doubts about pointers in C.
1) I have a function with prototype is :
my_funtion(char far * char);
I need to pass it an array of char which I have defined as follows:
char my_array[10]
The question is: is it allright to typecast to a far pointer? e.g.
int i=my_function( (char far *) ( (char *) my_array );
I think I am still only passing a near pointer, so how do I force
the segment to be passed also?
2) As expected, (char far *) NULL is NULL, but if I set
char near *x = NULL,
then (char far *)x is non-NULL (the segment is non-zero)!
This seems crazy, it means that if you have a prototyped function
with a far pointer argument (maybe NULL) and you have some
near-mode address from somewhere else (maybe NULL),
you have to handle the NULL case specially. What's going on?
I am using Borland Turbo-C 2.01 if it's relevant.
I have a couple of doubts about pointers in C.
1) I have a function with prototype is :
my_funtion(char far * char);
I need to pass it an array of char which I have defined as follows:
char my_array[10]
The question is: is it allright to typecast to a far pointer? e.g.
int i=my_function( (char far *) ( (char *) my_array );
I think I am still only passing a near pointer, so how do I force
the segment to be passed also?
2) As expected, (char far *) NULL is NULL, but if I set
char near *x = NULL,
then (char far *)x is non-NULL (the segment is non-zero)!
This seems crazy, it means that if you have a prototyped function
with a far pointer argument (maybe NULL) and you have some
near-mode address from somewhere else (maybe NULL),
you have to handle the NULL case specially. What's going on?
I am using Borland Turbo-C 2.01 if it's relevant.