All pastes #929757 Raw Edit

Something

public text v1 · immutable
·published 2008-03-06 00:02 UTC
rendered paste body
#include <regex.h>
#include <stdio.h>
int resposta;
int
match(const char *string, char *pattern)
{
    int    status;
    regex_t    re;

    if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
        return(0);      /* report error */
    }
    status = regexec(&re, string, (size_t) 0, NULL, 0);
    regfree(&re);
    if (status != 0) {
        return(0);      /* report error */
    }
    return(1);

}
main( )
   {
     FILE *ficheiro;
     char caracter;
     char caracterx[1];
     ficheiro = fopen("myfile.txt", "r");
     if (ficheiro == NULL) printf("File doesn't exist\n");
     else {
      do {
       caracter = getc(ficheiro); /* get one character from the file*/
	   caracterx[0]=caracter;
	   printf("%d",match(caracterx,"[0-9a-f]"));
       putchar(caracter); /* display it on the monitor*/
       } while (caracter != EOF); /* repeat until EOF (end of file)*/
     }
    fclose(ficheiro);
   }