All pastes #929634 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-05 22:21 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);     
    }
    status = regexec(&re, string, (size_t) 0, NULL, 0);
    regfree(&re);
    if (status != 0) {
        return(0);     
    }
    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); 
	   printf("%d",match("caracter","[0-9a-f]"));
       putchar(caracter); 
       } while (caracter != EOF); 
     }
    fclose(ficheiro);
   }