Is there a way to get an array of exactly n elements as a function input? (I know I can use an if
statement to check the input, but I need a "live warning" or a "compile error".)
Something like:
void getInt(int number /*This number must be exactly four digits, to be printed on four 7-segments*/){
}
void getCh(char *names /*exactly 4 chars*/){
}
int main(){
char boy[5] = "David";
char girl[4] = "Jane";
getCh(boy); //I need a compile error here (Or any other run-time warnings)
getCh(girl); //"Jane" is 4 characters. OK.
int num = 40, num2 = 12000;
getInt(num);
getInt(num2); //I need a warning/compile error here.
return 0;
}
Is there any feature? Like macro
s, pointer
s, etc.