Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access violation in this function? 2

Status
Not open for further replies.

ahoodin

Programmer
Jul 25, 2001
48
US
I use this function to parse delimeted data. When it is used in a loop sometimes I wonder about it. Normally solid dialogs will blink a bit when using data returned from it. Can anyone see anything?

TIA,

ahoodin


int parse(char *cSrc, char *cRet, int nSubstr, char* cDelimeter){//can use negative number to get last string in block
int nRetval = 0, nstrCtr=0;
char cTemp[1024]="";
char *token;
strcpy(cTemp,cSrc);
token = strtok( cTemp, cDelimeter );
while( token != NULL)
{ if ( strlen(token) >0 && token !=NULL ) nstrCtr++;
if (nstrCtr == nSubstr && token !=NULL) strcpy(cRet,token);
nRetval = nstrCtr;
token = strtok( NULL, cDelimeter );
}
if ((token == NULL) && (nSubstr < 0)) nRetval = nstrCtr;
return nRetval;
}
 
Per, I applaud you for doing your best.

>promoting the writing of clear and unobfuscated code on >several levels

Noted.


 
Or perhaps just tired of cleaning up other peoples mess.

/Per
[sub]
if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top