First Non Repeat

char find_first_nonrepeat(char *str)                                      // return char, not char*
{
    char *c1, pre_c;
 
    for (c1 = str, pre_c = *c1; *c1 != '\0' && *c1 == pre_c; c1++)        // c1 < strlen(str) Error! c1 is pointer of char, strlen return int
        pre_c = *c1;
 
    if (*c1 == '\0')
        return 0;
    else
        return *c1;                                                       
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License