#include char *match(char *s1, char * s2) { while ( *s1 == *s2++ ) if ( *s1++ == '=') return(s2); // field delimiter if (*s1 == '\0' && *(s2-1) == '=') return(s2); // match found return(NULL); } char aa[] = "foo=abcdefg"; int main() { char *s = match("foo", aa); cout << s << endl; }