G
gmclee
Hi there,
I need a program to extract a substring from the following pattern
xxxx<XXXXX>xxxx
therer, x and X are any character and the string between < and > is
what I need. I use the following program to extract the substring, but
something wrong
char* deangle(const char* lpStr)
{
char *lpBuf = (char *)lpStr;
char *p = strchr( lpBuf, '<' ) + 1;
if (!p) return NULL;
char *q = strchr( lpBuf, '>' );
if (!q) return NULL;
*q = '\0'; /* to make sure no extra characters at the end of the
substring
memcpy( lpBuf, p, q-p );
return lpBuf;
}
apply the function to some string like xxxx<http://www.abc.com>xxxx
what I get is "http://www.abc.comm"
I am wondering where is the double m come?
Thanks in advance
I need a program to extract a substring from the following pattern
xxxx<XXXXX>xxxx
therer, x and X are any character and the string between < and > is
what I need. I use the following program to extract the substring, but
something wrong
char* deangle(const char* lpStr)
{
char *lpBuf = (char *)lpStr;
char *p = strchr( lpBuf, '<' ) + 1;
if (!p) return NULL;
char *q = strchr( lpBuf, '>' );
if (!q) return NULL;
*q = '\0'; /* to make sure no extra characters at the end of the
substring
memcpy( lpBuf, p, q-p );
return lpBuf;
}
apply the function to some string like xxxx<http://www.abc.com>xxxx
what I get is "http://www.abc.comm"
I am wondering where is the double m come?
Thanks in advance