There's a strange thing appeared in my program
Code:
void process(FILE *fp, int width, int punctuation)
{
char single_c,
*temp_char,
whole_String[width],
temp_String[width];
int rc, i, pos = 0;
regex_t * myregex = calloc( 1, sizeof(regex_t) );
rc = regcomp( myregex, "[^a-zA-Z0-9 ]+", REG_EXTENDED | REG_NOSUB );
printf("RC from regcomp() = %d\n", rc); //regular expression.
//case: punctuation
while ( ( single_c = getc(fp) ) != EOF && width != pos)
{
temp_char = &single_c; //string point to char.
if( 0 == regexec(myregex, temp_char, 0 , 0 , 0 ) )
{
printf("%c\n", single_c );
}
else
{
printf("abc");
}
pos++;
}
free(myregex);
}
In the if statement , my program never go into else part.
Suppose when I give ":" to stdin, then this should print out "abc".
Can anyone tell me what my problem is?