I'm relatively new to C and I have a problem with the following:
 regex_t re;
 regmatch_t matches[2];
 int start;
 int end;
 int count = 0;
 int reti = regcomp(&re, "^(?:[a-zA-Z]|[a-zA-Z](?:[a-zA-Z0-9\\-])*[a-zA-Z0-9])(?:\\.(?:[a-zA-Z]|[a-zA-Z](?:[a-zA-Z0-9\\-])*[a-zA-Z0-9]))*$", REG_EXTENDED);
 while (1) {
   printf("Local = %s\n", local);
   reti = regexec(&re, local, 2, matches, 0);
  // More code here
 }
When I run this, I get a segmentation fault. 
local was defined as char *local and is being printed out correctly.
I ran the code using GDB and it turns out the issue is arising at the line:
reti = regexec(&re, local, 2, matches, 0);
I can't seem to figure out why.
This is the output from gdb:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7af8d42 in regexec () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) backtrace
#0  0x00007ffff7af8d42 in regexec () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000000000040092d in email_in (str=0x400aa8 "giri@gmail.com") attestdriver.c:70
#2  0x0000000000400780 in main () at testdriver.c:15
Would anyone have any ideas as to what might be the issue?
Thanks for your help.
 
    