A
andy_dufresne
hi,
i'd a question abt taking the difference between two pointers.
for eg: if you have 2 char pointers pointing to members of an array,
you advance one till you encounter a space then take the difference
between
the two, will give the correct length of the string irrespective of
whether char is represented by 2 bytes (like in unicode)?? i believe it
would give the correct length, because the compiler is responsible for
scaling the difference when one advances a pointer to point to the next
element like ptr++, or is it that pointer difference (subtraction
between two
pointers to members of the same array) is not pointer arithmetic and we
need
to scale it??
eg problem:
Orig string - char *s;
Ptrs, char *start = s, *end = s;
int length;
while(!isspace(*end))
end++;
length = end - start;
is this mentioned somewhere in the c std?? if so could someone pt me in
the right direction.
Thanks.
i'd a question abt taking the difference between two pointers.
for eg: if you have 2 char pointers pointing to members of an array,
you advance one till you encounter a space then take the difference
between
the two, will give the correct length of the string irrespective of
whether char is represented by 2 bytes (like in unicode)?? i believe it
would give the correct length, because the compiler is responsible for
scaling the difference when one advances a pointer to point to the next
element like ptr++, or is it that pointer difference (subtraction
between two
pointers to members of the same array) is not pointer arithmetic and we
need
to scale it??
eg problem:
Orig string - char *s;
Ptrs, char *start = s, *end = s;
int length;
while(!isspace(*end))
end++;
length = end - start;
is this mentioned somewhere in the c std?? if so could someone pt me in
the right direction.
Thanks.