improved printing of n-dimensional vectors
This commit is contained in:
@@ -29,3 +29,6 @@ install:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
sudo rm -f main /usr/lib/odweta/vector.o /usr/lib/odweta/file.o /usr/lib/odweta/libvector.so /usr/lib/odweta/libfile.so
|
sudo rm -f main /usr/lib/odweta/vector.o /usr/lib/odweta/file.o /usr/lib/odweta/libvector.so /usr/lib/odweta/libfile.so
|
||||||
|
|
||||||
|
cleanrepo:
|
||||||
|
rm -fr ./demo
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ int main(int argc, char **argv) {
|
|||||||
printf("pushing the first vector into the newly created one\n");
|
printf("pushing the first vector into the newly created one\n");
|
||||||
vectorPush(w, v);
|
vectorPush(w, v);
|
||||||
vectorPrint(w);
|
vectorPrint(w);
|
||||||
|
printf("once again\n");
|
||||||
|
vectorPush(w, v);
|
||||||
|
vectorPrint(w);
|
||||||
|
printf("popping\n");
|
||||||
|
vector_t *poppedv = (vector_t *)vectorPop(w);
|
||||||
|
printf("popped vector\n");
|
||||||
|
vectorPrint(poppedv);
|
||||||
|
printf("vector from which was popped after pop\n");
|
||||||
|
vectorPrint(w);
|
||||||
|
|
||||||
printf("initializing a char vector (variable-length string) with value \"Hello, world!\"\n");
|
printf("initializing a char vector (variable-length string) with value \"Hello, world!\"\n");
|
||||||
vector_t *charVector = vectorInit(CHAR);
|
vector_t *charVector = vectorInit(CHAR);
|
||||||
|
|||||||
+4
-2
@@ -42,7 +42,9 @@ _printVectorRecursive(vector_t* v, int depth) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < v->size - 2 && i != v->size - 1) {
|
if (i < v->size - 1 && v->type != CHAR) {
|
||||||
|
fprintf(stdout, ", ");
|
||||||
|
} else if (v->type == CHAR && i < v->size - 2 && v->size != 1) {
|
||||||
fprintf(stdout, ", ");
|
fprintf(stdout, ", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,4 +384,4 @@ vectorInsertAt(vector_t* v, int index, void* element) {
|
|||||||
perror("specify a valid vector type\n");
|
perror("specify a valid vector type\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user