hi everyone,

i finally got my code to search mulitple times against a string..

ie. the string is :

<title>hi all</title><dummy>sdf</dummy><title>hi everone</title>

and i search for <title> and it returns me the positions (of >)

7 and 39 in the string( note: the 2nd title tag's > is 39 spaces away from the first title tags > )

this works only when i debug my code using gdb...but when i run it ...it gives me a segfault...also , the thing of main concern is that my search function keeps saying(after i found the last title tag) that there are more title tags..instead of exiting the loop..and i think this causes the seg fault..

my code hits the segfault in the bolded line below

thanks for any help

int* search(char *file, char *currentSearch, char *tagType) {
	int error = 0;
    regex_t re;
    size_t a = 1;
    regmatch_t arrayOfMatches[2];
	int counter=0;
	int *Matches;
    if (regcomp(&re, currentSearch, REG_EXTENDED|REG_ICASE) != 0) {


	/* Finds the matches on the line */
	error = regexec (&re, file, a, &arrayOfMatches[0], 0);

	/* while matches found */
	while (error == 0) {    
			printf(" %d ", arrayOfMatches[counter].rm_eo);
			//Matches[counter] = arrayOfMatches[counter].rm_so;
  	  	/* This call to regexec() finds the next match */
    	error = regexec (&re, file + arrayOfMatches[counter].rm_eo, 1, &arrayOfMatches[counter+1], REG_NOTBOL);
    return Matches;

and this function is called like this..

startOfData = search("<title>hi all</title><dummy>sdf</dummy><title>hi everone</title>", "<title>", "start");