diff options
| author | Julian Weigt <juw@posteo.de> | 2026-02-09 22:10:20 +0100 |
|---|---|---|
| committer | Julian Weigt <juw@posteo.de> | 2026-02-09 22:10:20 +0100 |
| commit | b89e863851e4c5a0279129d423634d077fc85daf (patch) | |
| tree | a6a1d2f87c5bd3a5fb272c3cb8f3ee945210ef8b | |
| parent | c8f625564c6608887de0b8c1c879a3a8d7dfef98 (diff) | |
Implement printing human readable file.
| -rw-r--r-- | charf.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -475,14 +475,15 @@ void print_records(EXPTYPE exponents[P], VALUETYPE ratios[K+1][P], index_t indec printf("%s\n",s); } -void print_latex_records_to_file(EXPTYPE exponents[P], VALUETYPE ratios[K+1][P], index_t indeces[K+1][P], char* filename){ +void print_records_to_file(EXPTYPE exponents[P], VALUETYPE ratios[K+1][P], index_t indeces[K+1][P], char* filename, int format){ char s[STRING_SIZE]; - format_results(s, exponents, ratios, indeces, FORMAT_LATEX); + format_results(s, exponents, ratios, indeces, format); FILE *fptr; fptr = fopen(filename, "w"); fprintf(fptr, "%s\n",s); fclose(fptr); + printf("File \"%s\" written.\n",filename); } /*information given to each thread*/ @@ -570,9 +571,12 @@ int main() { if(finished >= NUM_THREADS) user_input_cont = false; } else if( 0 == strcmp(buff,"r")) print_records(exponents,records_ratio,records_index); - else if( 0 == strcmp(buff,"t")){ + else if( 0 == strcmp(buff,"t")*strcmp(buff,"p")){ + int format = 0; + if( 0 == strcmp(buff,"p")) format = FORMAT_TEXT; + else if( 0 == strcmp(buff,"t")) format = FORMAT_LATEX; getLine("Enter file name:\n", buff, sz); - print_latex_records_to_file(exponents,records_ratio,records_index,buff); + print_records_to_file(exponents,records_ratio,records_index,buff,format); } } while(user_input_cont); |
