#include <cstdio>
#include <math.h>
#include <cstdlib>
#include "test.h"
// test.h contains the function ABC() and
// arrayfire.h and
// using namespace af;
int main(int argc, char *argv[])
{
ABC(); // function
// here I am calling the variables defined in ABC()
af_print(C);
af_print(D);
#ifdef WIN32 // pause in Windows
if (!(argc == 2 && argv[1][0] == '-')) {
printf("hit [enter]...");
fflush(stdout);
getchar();
}
#endif
return 0;
}
In the figure above, there are two function scopes. Variables declared in one of the function scopes can't be used by any other function scope, they are local to that function.
Same with block scope, variables declared in a block can only be used in that block and children of that block.
Now for how this relates to your problem: The variables C and D are defined in the function ABC, that means their scope is in the ABC function only, other functions (like your main function) can't see or access the variables defined in the ABC, the variables are local in the scope of the ABC function.
There are many ways to solve the problem of accessing these variables from other functions, and the most common beginner way is to put the definition of those variables in the global scope. Then in the function you assign to the variables, something like
array C;
array D;
void ABC()
{
...
C = array(Q, 1, A);
D = array(Q, 1, B);
}