I'm trying to solve the following exercise:
Type a program that defines and uses the PRINTARRAY macro to print an array of integers. The macro should receive the array and the number of elements in array as argument
What I've done so far:
#include <stdio.h>
#include <stdlib.h>
#define LEN_VETOR 4
#define PRINTARRAY(vetor,length)while(length > 0){ \
printf("%d",vetor[length]);\
length--; \
} \
int main(void)
{
int vetor[] = {1,2,3,4};
PRINTARRAY(vetor,LEN_VETOR);
return 0;
}
The error I get when trying to compile:
error: lvalue required as decrement operand