calculating length of an substring
- From: "brasilino@xxxxxxxxx" <brasilino@xxxxxxxxx>
- Date: Fri, 29 Feb 2008 10:43:10 -0800 (PST)
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
.
- Follow-Ups:
- Re: calculating length of an substring
- From: Martin Ambuhl
- Re: calculating length of an substring
- From: burton . samogradNO
- Re: calculating length of an substring
- From: Micah Cowan
- Re: calculating length of an substring
- From: William Pursell
- Re: calculating length of an substring
- Prev by Date: Re: printf() causes core dump
- Next by Date: Re: dual core and c
- Previous by thread: array index and pointer, which is faster?
- Next by thread: Re: calculating length of an substring
- Index(es):
Relevant Pages
|