0

'a' was not declared in this scope. I can't spot the error. Pls advise.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

const int MAX = 10;


void constructArray_2 (int*, int);


int main ()
{
       
	srand (time (NULL));
    constructArray_2 (a, MAX);
      
}
void constructArray_2 (int *a, int size)
{
	for (int i = 0; i < size; i++)
	{
		*a = rand () % 10;
		++a;
	}
}
2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by makan007
0

constructArray_2 (a, MAX); You are passing in the value a to your function but there is no a defined in main(). Where is this value supposed to come from?

0

constructArray_2 (a, MAX); You are passing in the value a to your function but there is no a defined in main(). Where is this value supposed to come from?

Ok tks. I forgot to include "int a [MAX];" in main function.

Edited by makan007: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.