Search Results

Search found 2 results on 1 pages for 'lex0273'.

Page 1/1 | 1 

  • array iteration strstr in c

    - by lex0273
    I was wondering if it's safe to do the following iteration to find the first occurrence of str within the array or if there is a better way. Thanks #include <stdio.h> #include <string.h> const char * list[] = {"One","Two","Three","Four","Five"}; char *c(char * str) { int i; for (i = 0; i < 5; i++) { if (strstr(str, list[i]) != NULL) return list[i]; } return "Not Found"; } int main() { char str[] = "This is a simple string of hshhs wo a char"; printf("%s", c(str)); return 0; }

    Read the article

  • strstr matching first occurrence in c

    - by lex0273
    I was wondering how could I match the string "just" in str1 if str1 contains the strings as: "this is just\2323 a test" // "just" will always be the same I'm trying to match it using strstr but so far it won't match because of the \xxxx Any suggestions on how to match it? Thanks

    Read the article

1