Hi,
I've been developing some code that parses output reports and re-reports on information that is of interest. I utilize strtok quite heavily in this program and I have run into the situation where my final strtok call may or may not return some info. Depending on if there is info returned will dictate my branch in an IF statement. Code snipit:
while (fgets(buffer, 133, ofp) != NULL)
{
if (!strncmp(&buffer[1], "Queue:", 6))
{
memset(oqnamlib,'\0',sizeof(oqnamlib));
if (strncmp(&buffer[10]," ",10))
{
strncpy(que,&buffer[10],10);
token=strtok(buffer," ");
token=strtok(NULL," :");
token=strtok(NULL,":");
token=strtok(NULL," :");
len = strlen(&token[0]);
if (len <= 0)
If the last call to strtok does not find anymore info, i.e. token becomes NULL, then if I do the strlen call the code blows up at runtime. token is defined as char *token. I have tried the strlen command with token, *token (doesn't compile), &token and &token[0]. Any suggestions?
{