Hi there! I am trying to write a program that generates 6 random lines in an 80X20 2d array.
I keep getting the error "macro "arc4random_uniform" passed 1 arguments, but takes just 0", can someone tell me how to fix this please?
int main(int argc, char *argv)
// fill the sky with spaces
memset(sky, '.', nRows * nCols);
for (int i = 0; i < 6; ++i)
int x1, y1, x2, y2;
// choose points on the perimeter.
// if x == 0 or nCols - 1, the y can be anything.
// if x is between 0 and yCols, y MUST BE BOTTOM (0) or TOP nRows - 1
x1 = arc4random_uniform(nCols);
if (x1 == 0 || x1 == nCols - 1)
y1 = arc4random_uniform(nRows);
y1 = (arc4random_uniform(2) ? 0 : nRows - 1);
#define arc4random_uniform() Macro which takes 0 parameters. arc4random_uniform(2) And you passed 1 into it.
Solution: do not pass parameters into it or rewrite your macro to make sense.
Even better: do not use macros. The are evil. Inline functions are better in every way. #define MIN(a,b) ((a)<(b)?(a):(b)) Use std::min()