I want to use an array from a function HashTableInit
to printHash
. So, I defined it globally. But array's parameters are present in function HashTableInit
. I don't want to take array by returning the function, because to use return I will need to call the whole function in printHash
, and it will disturb my whole code.
void HashTableInit(int TableSize, int Key) {
//Create a space for HashTable as given in variable TableSize
struct hashTableNode * HT[TableSize];
for (int i = 0; i < TableSize; i++) {
HT[i] = (struct hashTableNode*) malloc(sizeof (struct hashTableNode));
HT[i] ->Key = 0;
HT[i] ->next = NULL;
}
Here, TableSize will be available after this function executes. But how could I define array globally with parameters.