#include #include #include #include #include #include #include #include #define DAN 69 #define NOC 420 #define JUTRO 1337 int main(int argc, char *argv[]) { if(argc != 1+2) { fprintf(stderr, "usage: %s \n", argv[0]); return 1; } char *delim = argv[1]; int stolpec = atoi(argv[2]); char **list; size_t i, len; char line[1337]; int iter = 0; int status = DAN; double zacetna_vrednost; fgets(line, 1337, stdin); line[strcspn(line, "\n")] = 0; while(1) { explode(line, delim, &list, &len); if(iter == 0) { zacetna_vrednost = atof(list[stolpec]); } for(int j = 0; j < len; j++) if(j == len-1) if(j == stolpec) fprintf(stdout, "%f", atof(list[j])-zacetna_vrednost); else fprintf(stdout, "%s", list[j]); else if(j == stolpec) fprintf(stdout, "%f%s", atof(list[j])-zacetna_vrednost, delim); else fprintf(stdout, "%s%s", list[j], delim); fprintf(stdout, "\n"); /* free list */ for(i = 0; i < len; ++i) { free(list[i]); } free(list); fgets(line, 1337, stdin); if(feof(stdin)) { break; } // fprintf(stderr, "d: %s", line); line[strcspn(line, "\n")] = 0; iter++; } return 0; }