#include <stdio.h>
#define UNITS {'*', '#', '%', '!', '+', '$', '=', '-'}
#define PrintDigit(c, d) (for (i=0; i < c ; i++)putchar(unit[d]);)
char unit[] = UNITS;
int main( ) {
int i, element=4;
PrintDigit(10, element);
putchar('\n');
return 0;
}
I have a function PrintDigit()that works as expected. While trying to turn the function into #define, however, gcc continues to throw a syntax error in the for loop. Any idea what the problem is?
source
share