R
raphfrk
Assuming this program:
#include <stdio.h>
int main( int argc, char *argv[] )
{
int a[100];
int b[100];
int *pa;
int *b_top;
pa = a + 20;
b_top = b + 99;
if( (pa >= b) && (pa<=b_top) )
{
printf( "Pa is pointing to an element in array b\n" );
}
else
{
printf( "Pa is not pointing to an element in array b\n" );
}
}
Will the else branch always execute in theory (it probably will in
practice)?
Does the standard define what comparison between pointers which point
to different arrays do?
In principle, there could be a rule that for all possible pointers,
there must be an ordering.
What if the pointers were void pointers in the comparisons?
i.e. would
((void *)Pa) < ((void *)b_top)
give the same answer as
Pa < b_top
for all Pa and b_top
#include <stdio.h>
int main( int argc, char *argv[] )
{
int a[100];
int b[100];
int *pa;
int *b_top;
pa = a + 20;
b_top = b + 99;
if( (pa >= b) && (pa<=b_top) )
{
printf( "Pa is pointing to an element in array b\n" );
}
else
{
printf( "Pa is not pointing to an element in array b\n" );
}
}
Will the else branch always execute in theory (it probably will in
practice)?
Does the standard define what comparison between pointers which point
to different arrays do?
In principle, there could be a rule that for all possible pointers,
there must be an ordering.
What if the pointers were void pointers in the comparisons?
i.e. would
((void *)Pa) < ((void *)b_top)
give the same answer as
Pa < b_top
for all Pa and b_top