0

I meant, something that we can use this way:

char string1[] = "???, buddy*\0";
char string2[] = "Hey, buddy, hello!\0";
if (like(string1, string2) 
    puts("strings are similar!");
else
    puts("string are different!");
PinkiNice
  • 1,455
  • 2
  • 13
  • 19
  • 1
    not sure strcmp will do it. I suspect the OP would expect string1 and string2 to be 'like' seeing as how, if we treat string1 as a regular expression, then string2 would match. That said, the OP might want to look at a regular expression library for C – thurizas Dec 23 '15 at 18:23
  • 1
    @haccks Does `strcmp` accept mask symbols? Like `?` and `*`? – PinkiNice Dec 23 '15 at 18:24
  • I don't think this is a duplicate. OP is asking for globs, not regular expressions. – fuz Dec 23 '15 at 19:08
  • POSIX provides functions for globs (wildcards like `?` and `*`) in `fnmatch.h`. The function you need is called `fnmatch()`. – fuz Dec 23 '15 at 19:09
  • If you want something simple like "%xxx%", you could use strstr. – cup Dec 23 '15 at 20:48

1 Answers1

0

You want to use a regular expression library. See this question for the ANSI library information: Regular expressions in C: examples?

Community
  • 1
  • 1
bruceg
  • 2,433
  • 1
  • 22
  • 29