1
0

feat: Initial commit

This commit is contained in:
2024-03-22 17:37:24 +01:00
parent 4288bd63a1
commit 6732a7a166
120 changed files with 9620 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// Laboratorio 8 - Esercizio 2 - Item.c
// Matteo Schiff - s295565
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Item.h"
Item ITEMcreate(char *name, char *subnet) {
Item t;
strncpy(t.name, name, MAX_STR+1);
strncpy(t.subnet, subnet, MAX_STR+1);
return t;
}
Item ITEMread(FILE * fp) {
Item item;
fscanf(fp, " %s %s", item.name, item.subnet);
return item;
}
Item ITEMnull() {
Item t;
strcpy(t.name, "");
strcpy(t.subnet, "");
return t;
}
static int compareItem(const void *a, const void *b) {
return strcmp((*(Item*)a).name, (*(Item*)b).name);
}
void ITEMsort(Item *v, int N) {
qsort(v, N, sizeof(Item), compareItem);
}