There is a code snippet,
int matchhere(char *regexp, char *text)
{
/* do sth */
return *test== '\0';
}
I do not understand what does
return *test== '\0';
mean. Or what it will return? How does “==” function here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
*testpart reads the first character for the C string (a C string is merely a bunch of characters starting at a given address, and the*foooperator looks at that address which happens to contain the first character). By definition, a C string ends with a null byte ('\0'or simply0).So this tests whether the first character is the end-of-string character. Or in other words: it tests whether the string is empty. That comparison result (1 if empty, 0 if non-empty) is returned.