Re: calculating length of an substring
- From: William Pursell <bill.pursell@xxxxxxxxx>
- Date: Fri, 29 Feb 2008 10:52:44 -0800 (PST)
On Feb 29, 6:43 pm, "brasil...@xxxxxxxxx" <brasil...@xxxxxxxxx> wrote:
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;
You need to check that both s and e are notnull, and you probably
mean:
len = (int) (e - s);
Your version is equivalent to:
len = ((int)s) - e;
and the compiler is complaining about subtracting a pointer
from an int.
.
- References:
- calculating length of an substring
- From: brasilino@xxxxxxxxx
- calculating length of an substring
- Prev by Date: Re: dual core and c
- Next by Date: Re: Variable-sized lines of text in linked list
- Previous by thread: calculating length of an substring
- Next by thread: Re: calculating length of an substring
- Index(es):
Relevant Pages
|