Reputation: 55
I have to write a funcion that checks if two strings are equal. If so it returns 1 otherwise 0. But, if the second string contains a replaceable asterisk it will be replaced in order to make the strings equal.For example "main.c" and "*.c" are equal because "main" can be replace with "*". How do i implement this ? Using strcmp ?
Upvotes: 0
Views: 179
Reputation:
If you're allowed to use all C library functions, there's one that does this:
if (fnmatch("*.c", "main.c", 0)) {
// it's a match
}
See the manual page for details.
Upvotes: 4