#include <stddef.h>
#include <stdio.h>
#include <regex.h>  
#include <stdlib.h>  
#include <string.h>    

int main (int argc, char *argv[])
{
	/*
    if (argc < 2) {
        fprintf(stderr, "Usage: %s number\n", argv[0]);
        return(1);
    }

    int num = atoi(argv[1]);
    */
    int num=41;
    printf("%d\n",num);

    regex_t regex;
    char    buf [255];
    char    str [num+1];

    memset(str,'1',num);
    str[num] = 0;
    puts(str);

    regcomp(&regex, "^(11+)\\1+$", REG_EXTENDED);

    int r = regexec(&regex, str, 0, NULL, 0);

    //If a match is found, the regexec() function returns 0. 
    if (0 == r) {
        puts("Not Prime");
    }
    //If no match is found, the regexec() function returns REG_NOMATCH. 	
    else if (REG_NOMATCH == r) {
        puts("Prime");
    }
    //Otherwise, it returns a nonzero value indicating an error. 		
    else {
        regerror(r, &regex, buf, sizeof(buf));
        fprintf(stderr, "Error: %d %s\n",r , buf);
        return(1);
    }

}
