calculating length of an substring



Hi Folks:

I'm trying to calculating a substring length directly from pointer
address, like this:

char *e = NULL, *s = NULL;
int len = 0;

s = strchr (url,'.');
e = strrchr (url,'?');
len = (int) s - e;

Since 's' and 'e' are pointers, I think that's can be make a math
over it, like 's++'.

Using gcc 4.1.2 (on glibc 2.6 and Linux 2.6.23) it points the
following error:

"error: invalid operands to binary -"

So, how can I calculate this length in a fancy way? I don't want to
loop through it.

thanks a lot in advance
Lucas Brasilino
.



Relevant Pages