EasyCSV/tests/02/02.c

54 lines
1.0 KiB
C
Raw Normal View History

2018-02-11 18:14:34 +01:00
#include "../include/easycsv/easycsv.h"
int main(void)
{
const char CSV_FP[] = "02.csv";
struct easycsv *csv = easycsv_init(CSV_FP, EASYCSV_W);
if (csv == NULL) {
fprintf(stderr, "Failed to load %s\n", CSV_FP);
return -1;
}
const char mod_one[] = "first-mod-deluxe-edition";
const char *paths_one[5] = {
"FILEPATH1ONE",
"FILEPATH2ONE",
"FILEPATH3ONE",
"FILEPATH4ONE",
"FILEPATH5ONE"
};
const char mod_two[] = "second-mod-gold-edition";
const char *paths_two[4] = {
"FILEPATH1TWO",
"FILEPATH2TWO",
"FILEPATH3TWO",
"FILEPATH4TWO"
};
if (easycsv_pushcolumn(csv, mod_one) < 0) {
return -1;
}
for (size_t st = 0; st < 5; st++) {
if (easycsv_pushcolumnvalue(csv, mod_one, paths_one[st]) < 0) return -1;
}
if (easycsv_pushcolumn(csv, mod_two) < 0) {
return -1;
}
for (size_t st = 0; st < 4; st++) {
if (easycsv_pushcolumnvalue(csv, mod_two, paths_two[st]) < 0) return -1;
}
easycsv_free(csv);
csv = NULL;
return 0;
}