I want to share accountrefence variable to another c file where
the other c file has accountrefence = NULL;
and is having another called function which is using accountrefence variable.
The second function always sees the variable as NULL. how can I share the variable between the 2 called function so that whenever the variable changes the 2nd called function sees it and do operations upon it? the functions are in the first c file the main is in the second c file
EN_serverError_t isValidAccount(ST_cardData_t* cardData, ST_accountsDB_t* accountRefrence)
for (int i = 0 ; i < 3; i++)
{
//printf("\n%s\n", accountRefrence[i].primaryAccountNumber);
if (!(strcmp(cardData->primaryAccountNumber, accountsDB[i].primaryAccountNumber)))
{
accountRefrence = &accountsDB[i];
return SERVER_OK;
}
}
return ACCOUNT_NOT_FOUND;
}
```
EN_serverError_t isBlockedAccount(ST_accountsDB_t* accountRefrence)
{
printf("%p", accountRefrence);
if (accountRefrence->state == RUNNING)
{
return SERVER_OK;
}
else
{
return BLOCKED_ACCOUNT;
}
}
ST_transaction_t* accountRefrence = NULL;
int main(void)
{
CheckAccountDB = isValidAccount(cardData, accountRefrence);
if (CheckAccountDB == ACCOUNT_NOT_FOUND)
{
printf("\nAccount Doesn't Exist");
}
else
{
printf("\nAccount Exist");
}
CheckAccountState = isBlockedAccount(accountRefrence);
if (CheckAccountState == SERVER_OK)
{
printf("Account is Running");
}
else
{
printf("Account is Blocked");
}
return 0;
}