I can get the code working without using a function, but as it is I get this error message:
error: expected expression before 'int'
is_authorized(x,int *authPorts[N]);
By researching this I think it might be something to do with passing an array to a function but everywhere I found something that seemed like it might be relevant had too much information that I didn't understand for me to use it.
Here's my code:
#include <stdio.h>
#define N 8
int is_authorized(int port,int *auth_ports[]);
int main(void) {
int x = 73;
/* authorised ports: */
int authPorts[N] = {20,73,60,80,212,434,2211,434};
is_authorized(x,int *authPorts[N]);
return 0;
}
int is_authorized(int port, int *auth_ports[]){
int i;
for (i = 0; i < N; i++){
if (port == *auth_ports[i])
printf("1");
else
printf("0");}
}