Q:

Using pointer in boolean expression of if statement

I am getting input as argv, argc and I want to return TRUE of FALSE according to the input. My code is :
int is_valid_regexp(const char* regexp);
int main(int argc, char *argv[])
{   
  if (!is_valid_regexp(argv[1])){
    fprintf(stderr, "wrong regular expression format:%s", argv[1]);
    return(EXIT_FAILURE):
  }
  return (EXIT_SUCCESS);
}

int is_valid_regexp(const char* regexp)
{
  do{
    if(*regexp == '\\')
      return FALSE;
  }while (regexp++ != '\0');
  return TRUE;
}

The program executes and then stops working. I think something is wrong with if(*regexp == '\\') return FALSE - the program works well if I exclude that part. Does it have something to do with pointer problem?

A:

 }while (regexp++ != '\0');

Here, regexp is a POINTER, which is equal to address of area of memory. regexp++ just shift right on one position this pointer. As type of pointer is size_t (unsigned __int32) you go outside your string.
Use 
`}while (*regexp++ != '\0');` 

to solve your problem.

