#include <stdio.h>
#define UNITS {'*', '#', '%', '!', '+', '$', '=', '-'}
#define PrintDigit(c, d) (for (i=0; i < c ; i++)putchar(unit[d]);)
char unit[] = UNITS;
//void PrintDigit(c, element) {
// int i;
// for (i=0; i < c ; i++)
// putchar(unit[element]);
//}
int main( ) {
int i, element=4;
PrintDigit(10, element);
putchar('\n');
return 0;
}
I have the function here PrintDigit() which works as expected. When attempting to turn the function into a #define however gcc keeps throwing a syntax error on the for loop. Any idea what the problem is?