This example uses WinNextChar to traverse a string until a specified character is found, while maintaining an index to point to the character's position.
#define INCL_WINCOUNTRY /* Window Country Functions */ #include <os2.h> HAB hab; /* Anchor-block handle */ ULONG idCodepage=437; /* Code page identity of both strings */ ULONG idCountryCode=1; /* Country code */ char pszString1[10]; /* First string */ char *pszNextChar; /* Next character */ char *pszCurrentChar; /* Current character */ ULONG ulIndex; /* Array index */ /* Set initial values */ strcpy(pszString1,"Compare"); pszCurrentChar = pszString1; ulIndex = 0; do { pszNextChar = WinNextChar(habMain, 437, 0, pszCurrentChar); /* The next line is necessary to get the next char */ pszCurrentChar = pszNextChar; /* Set emergency escape route, just in case */ ulIndex = ulIndex + 1; if (ulIndex >10) break; } while (*pszNextChar != (char)NULL);