> On Behalf Of S.V.BADARI NARAYANA MURTHY
>
> i want to extract substring from a string. if i am using
> StrStr function.
>
> Char* str.str1;
> Char c;
> str="xxxxxxxxx/yyyyyyyy"
> for(str1=str,c=*str;(c&&c!="/");)
> c=*str1++;
> *****************
> here i got the problem, showing Junk value , no error
> message(||)***************
> *(str1--)=NULL;
> ************************************************
>
> i want extraxt before "/" .
>
> first i has find position of "/", after that i before "/" NULL will be
> assigned.
>
> please tell me where i went to wrong.
Way too complicated ...
==[ Begin Code snippet ]=====================================
Char* szString, szTemp ;
UInt8 nLocation ; // Location of '/' in string
szTemp = StrChr(szString,'/') ;
if (szTemp != NULL) // Just being clear ...
{
nLocation = szTemp - szString ;
szTemp = StrNCopy(szTemp,szString,nLocation) ;
// An alternative is to set the character at the
// "nLocation" that way found to be '/0'
}
else
{
// '/' wasn't found in string ...
}
==[ End Code snippet ]=======================================
You have a heap of String function available to you in the String Manager
without resorting to shifting bits and looping. Use them.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/