Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So I wrote the following header file VariableVector.h:

#define VECTOR_INITIAL_CAPACITY 20

struct _Variable {
    char *variableName;
    char *arrayOfElements;
    int32_t address;
};
typedef struct _Variable Variable;

struct _VariableVector {
    int size; // elements full in array
    int capacity; // total available elements
    Variable variables[VECTOR_INITIAL_CAPACITY];
};
typedef struct _VariableVector VariableVector;

void init(VariableVector *variableVector);

void append(Variable *variable);

Variable* find(char *variableName);

And in my VariableVector.c file I would like to implement all of the above methods but I do not know how.

#include "VariableVector.h"

void init(VariableVector *variableVector) {
    variableVector->size = 0;
    variableVector->capacity = VECTOR_INITIAL_CAPACITY;

    // allocate memory for variableVector??
}

void append(Variable *variable) {

}

Variable* find(char *variableName) {
    return NULL ;
}

can anyone offer suggestions?

share|improve this question
 
What is your specific question? Asking for unspecified suggestions doesn't count. –  Raymond Chen 1 hour ago
 
Identifiers starting with an underscore followed by an uppercase letter are reserved for the implementation. This is why many of the new C keywords are things like _Bool, _Atomic, _Thread_local, _Generic etc. –  dreamlax 1 hour ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.