-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector.c
51 lines (42 loc) · 896 Bytes
/
vector.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vector.h"
#define ERR(source) (perror(source),\
fprintf(stderr,"%s:%d\n",__FILE__,__LINE__),\
exit(EXIT_FAILURE))
VectorIndices VectorIndicesNuevo(int tamano)
{
VectorIndices a;
a = (VectorIndices)calloc(sizeof(int),tamano);
if (!a) ERR("malloc");
return a;
}
void VectorIndicesElimina(VectorIndices vi)
{
free(vi);
}
void VectorIndicesImprime(FILE * fd, VectorIndices vi, int tamano)
{
if (!vi || !fd) ERR("null arguments");
for (int i=0;i<tamano;i++)
{
fprintf(fd,"%d", vi[i]);
}
fprintf(fd,"\n");
}
void VectorIndicesSetI(VectorIndices vi, int i)
{
if (!vi) ERR("null argument");
vi[i]=1;
}
void VectorIndicesUnsetI(VectorIndices vi, int i)
{
if (!vi) ERR("null argument");
vi[i]=0;
}
int VectorIndicesGetI(VectorIndices vi, int i)
{
if (!vi) ERR("null argument");
return vi[i];
}