Here i have one string means character array. this array contains separator character also. Now i want to take out only strings without this separator.
I am using strtok function.
I want to separate all my words with this separator.
But here i am getting some problems in this code.
Please Let me know if i am doing something wrong or tell me different way simple and easy way to achieve this thing,consider memory risk also.
Here this line pch = strtok (str,&sep); get nothing. Problem is here only.
Code
/* strtok example */
#include <stdio.h>
#include <string.h>
#define SEPRATOR 0x03
int main ()
{
    char str[1024];
    int count = 0;
    char sep;
    memset(str,0,1024);
    sep = SEPRATOR;
    memcpy(str,"1",strlen("1"));
    count = count + strlen("1");
    str[count++] = sep;
    memcpy(str+count,"0",strlen("0"));
    count = count + strlen("0");
    str[count++] = sep;
    memcpy(str+count,"2",strlen("2"));
    count = count + strlen("2");
    str[count++] = sep;
    memcpy(str+count,"abc_1.0.xyz",strlen("abc_1.0.xyz"));
    count = count + strlen("abc_1.0.xyz");
    str[count++] = sep;
    memcpy(str+count,"3",strlen("3"));
    count = count + strlen("3");
    str[count++] = sep;
    memcpy(str+count,"23455.456",strlen("23455.456"));
    count = count + strlen("23455.456");
    printf("Input String = %s\n",str);
    char * pch;
    int pchcount = 0;
    pch = strtok (str,&sep);
    while (pch != NULL)
    {
        pchcount++;
        printf ("%d === %s\n",pchcount,pch);
        pch = strtok (NULL,&sep);
    }
    return 0;
}
 
     
    