Get certain parts out of a string using C
===

Evening everyone hope on of you gurus can help. I am trying to find the answer to this issue I need to read the data out of the string below by searching the tags. i.e IZTAG UKPART etc however the code I am using is no good as it only stores the 1st part of it for example UKPART = 12999 and misses out the -0112. Is there a better way to search strings ?

This is the code i have so far.

    #include <stdio.h>  
    #include <string.h>  
    #include <windows.h>  
     
    int main ()  
    {  
        // in my application this comes from the handle and readfile 
        char buffer[255]="IZTAG-12345...UKPART=12999-0112...ISUE-125" ;     
        // 
        int i;  
        int codes[256];   
        char *pos = buffer;   
        size_t current = 0;   
        //   
        while ((pos=strstr(pos, "UKPART")) != NULL) {   
            if (sscanf(pos, "UKPART - %d", codes+current))   
                ++current;   
            pos += 4;   
        }   
     
        for (i=0; i<current; i++)  
            printf("%d\n", codes[i]);  
        system("pause"); 
        return 0;  
    }  

