Skip to content
Snippets Groups Projects
Commit 8987a31e authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Add Opaque struct and create function

parent f4024bb2
No related branches found
No related tags found
No related merge requests found
{
"files.associations": {
"stdlib.h": "c",
"stdio.h": "c"
}
}
\ No newline at end of file
/*
Autheur : Abivarman KANDIAH
Date : 11/01/2022
Date : 22/02/2022
Fichier : vectors.h
Descritpion : Vectors functions header
*/
......@@ -8,11 +8,16 @@
#ifndef _VECTORS_H_
#define _VECTORS_H_
#define VECTOR_INIT_CAPACITY 4
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
typedef int type;
typedef struct vector_* vector;
vector vector_create();
#endif
\ No newline at end of file
......@@ -12,6 +12,7 @@
int main()
{
vector test = vector_create();
return 0;
}
\ No newline at end of file
......@@ -7,4 +7,19 @@
#include "../header/vectors.h"
struct vector_ {
type *content; // actual content of the vector
int capacity; // capacity allocated
int length; // actual length
};
vector vector_create()
{
vector vec = malloc(sizeof(*vec)); //!BUG POSSIBLE
vec->content = malloc(sizeof(type) * VECTOR_INIT_CAPACITY);
vec->capacity = VECTOR_INIT_CAPACITY;
vec->length = 0;
return vec;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment