/// @file /// @brief Task B /// gcc -g -fsanitize=address -std=c11 taskB.c -Imodules -o taskB && ./taskB #include "iue-io/ccsv.h" // struct Table, table_append_copy, table_clear, iueio_savetxt, iueio_loadtxt #include // size_t #include // printf int main() { //writing Data manually FILE *fpt; fpt = fopen("table1m.csv","w+"); fprintf(fpt,"1e-10, 1e1, 1e10, 1e100\n"); fprintf(fpt,"2e-10, 2e1, 2e10, 2e100\n"); fprintf(fpt,"3e-10, 3e1, 3e10, 3e100\n"); fclose(fpt); /// @todo use the functionality in 'iue-io/ccsv.h' to implement the following steps: /// 1. create a table of type `struct Table` using the function /// 'table_append_copy' /// containing these values: /// 1e-10, 1e1, 1e10, 1e100 /// 2e-10, 2e1, 2e10, 2e100 /// 3e-10, 3e1, 3e10, 3e100 /// 2. save the table as 'table1.csv' using the function 'iueio_savetxt') /// - use ',' as separator /// - use '#' as comment /// 3. load the just saved table again using 'iueio_loadtxt' /// 4. multiply each value in the table by 1.001 /// 5. store the modified table as 'table2.csv' /// 6. use 'table_clear' appropriately at the end of your program double mult=1.001; {// write struct Table table1 = {NULL, 0}; double data[4] = {1e-10, 1e1, 1e10, 1e100}; double data1[4] = {2e-10, 2e1, 2e10, 2e100}; double data2[4] = {3e-10, 3e1, 3e10, 3e100}; table_append_copy(&table1, data, 4); table_append_copy(&table1, data1, 4); table_append_copy(&table1, data2, 4); iueio_savetxt("table1.csv", &table1, ';',"", '#'); table_clear(&table1); } { // read && write struct Table table2 = {NULL, 0}; struct Table table3 = {NULL, 0}; iueio_loadtxt("table1.csv", &table2, ';', '#'); for (size_t i = 0; i != table2.n; ++i) { double data[4]; for (size_t j = 0; j != table2.rows[i].n; ++j) data[j]=(table2.rows[i].values[j])*1.001; table_append_copy(&table3, data, 4); } iueio_savetxt("table2.csv", &table3, ';',"", '#'); table_clear(&table2); table_clear(&table3); } return 0; }