Error about the scope of variable in c++

Hi all,
I have a function and a structure both of which are defined outside the main function. I want to assign the value for my structure variable inside the function.The following are my function and structure

Function:
void drow(char ar[][50],int i)
{
for(int j = 0; j< 50; j++) {
asd.a[i][j]=ar[i][j];
}
//cout << endl;
}
Structure:
struct S
{
char a[1][50];
};
struct S asd;

The following is my error:
In function drow:
asd is not declared in this scope.
Can anyone tell me how do I avoid this error and how to assign value to structure variable inside the function
Definition of asd has to go before definition of drow().
The compiler searches declarations of names before their usage.

In you example you could declare the structure array as a parameter of the function. For example

void drow(char dst[][50], const char src[][50],int i );

Topic archived. No new replies allowed.