From b89e863851e4c5a0279129d423634d077fc85daf Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Mon, 9 Feb 2026 22:10:20 +0100 Subject: Implement printing human readable file. --- charf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/charf.c b/charf.c index e77c1aa..d2fbd3b 100644 --- a/charf.c +++ b/charf.c @@ -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); -- cgit v1.2.3