Hello

I have a list of data, which looks something like below
www.clickajob.co.uk%2Fprofiles%2F316%2F6%2F|a/TLT10911641168.google
www.ukdata.com%2Fcompany-listings%2FAd-16.html|a/TLT10911767856.google

I need to parse this data so i am left with

www.clickajob.co.uk|TLT10911641168.google
www.ukdata.com|TLT10911767856.google

Does anyone know how to help me? I have the following so far

if ( fp == NULL )
    {
        printf("Error opening %s\n", filename );
        return(1);
    }
    printf("Sucessfully opened %s\n", filename );

    while(fgets(string,sizeof(string), fp )!= NULL )
    {
         printf("Start = %s\n", string );
         if( ptr = strtok(string,"%"))
         {
             memcpy(web,ptr,sizeof(web));
             printf("web = %s\n", web );
             if ( ptr = strtok(NULL,"|" ))
             {
                 printf("ptr = %\n", ptr );
                 memcpy(Company,ptr,sizeof(Company));
                 printf("BURN = %\n", Company );
             }
         }
    }

If the strings are always in that exact format than this should work.

int main()
{
    char s1[] = "www.clickajob.co.uk%2Fprofiles%2F316%2F6%2F|a/TLT10911641168.google";
    char s1a[50] = {0};
    char* pos;

    pos = strchr(s1,'%');
    *pos++ = 0;
    strcpy(s1a, s1);
    pos = strchr(pos,'/');
    strcat(s1a,"|");
    strcat(s1a,pos+1);
    printf("%s\n", s1a);
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.