c++ - Creating my own std::vector in C program -


How do I know the code with C ++, though this is my first time, I try to use C I am

I have also tried to define a cvector.h and cVector.c to implement some std :: vector functionality. But when I compile my code, I get the following error.

The code is similar here:

cVector.h

  #define VECTOR_INITIAL_CAPACITY 520 Typedef structure {int size; // slot so far used int capacity; // Total available slots int * data; // array of integer we are storing vector; Zero vector_init (vector * vector);  

cVector.c

  #include "cVector.h" #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; Zero vector_init (vector * vector) {// initial size and capacity vector-> size = 0; Vector-> capacity = VECTOR_INITIAL_CAPACITY; // vector-> Data vector-> Data = Molec (// size) for potential vector-> // allocated memory;}  

is used here:

  #include "CVector.h" vector bar; vector_init (& amp; bar); int main {....}  

and finally error:

  Ser.c: 135: 13: Error: Required declaration specifier or '..' first 'and' token  

You can not make a file call at the function, in this way the scope requires you to move the call to the function (eg main ).

< / Div>

Comments