Mail Archives: djgpp/2002/10/24/10:20:31
--Apple-Mail-4--820032763
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
The tutorial on your site is great, but I think some sample code would
be in order. I think that my code *should* work, but when I printf, it
comes up blank, sorry to sound like a n00b, but in C regex, I sure as
heck am.
#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
int main (int argc, const char * argv[]) {
regex_t regex;
regmatch_t matches[4];
char string[] = "uhohthismaynotwork";
regcomp(®ex,"uhoh\([[:alnum:]]\)",0);
regexec(®ex,string,4,matches,0);
printf("%s - %s\n",string,string+matches[0].rm_so);
return 0;
}
and I get:
CREGEX has exited due to signal 11 (SIGSEGV).
during the printf statement. rm_so is obviously out of bounds, but I
don't have a clue why that would be.
Thanks a lot.
Daniel Staudigel
--Apple-Mail-4--820032763
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
charset=US-ASCII
The tutorial on your site is great, but I think some sample code would
be in order. I think that my code *should* work, but when I printf, it
comes up blank, sorry to sound like a n00b, but in C regex, I sure as
heck am.
#include <<stdio.h>
#include <<sys/types.h>
#include <<regex.h>
int main (int argc, const char * argv[]) {
regex_t regex;
regmatch_t matches[4];
char string[] = "uhohthismaynotwork";
regcomp(®ex,"uhoh\([[:alnum:]]\)",0);
regexec(®ex,string,4,matches,0);
printf("%s - %s\n",string,string+matches[0].rm_so);
return 0;
}
and I get:
CREGEX has exited due to signal 11 (SIGSEGV).
during the printf statement. rm_so is obviously out of bounds, but I
don't have a clue why that would be.
Thanks a lot.
Daniel Staudigel
--Apple-Mail-4--820032763--
- Raw text -