All pastes #929640 Raw Edit

Miscellany

public c v1 · immutable
·published 2008-03-05 22:22 UTC
rendered paste body
#include <regex.h>#include <stdio.h>int resposta;intmatch(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;	      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*/	   printf("%d",match(caracter,"[0-9a-f]"));       putchar(caracter); /* display it on the monitor*/       } while (caracter != EOF); /* repeat until EOF (end of file)*/     }    fclose(ficheiro);   }