aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Weigt <juw@posteo.de>2026-02-09 22:11:31 +0100
committerJulian Weigt <juw@posteo.de>2026-02-09 22:11:31 +0100
commit98399651862197ddf0f8215460ca91c8592c761f (patch)
treeb5d62ca1318b5159b3cd262c295f8c3d67c897d7
parentb89e863851e4c5a0279129d423634d077fc85daf (diff)
Print message after each user input.
-rw-r--r--charf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/charf.c b/charf.c
index d2fbd3b..56e7b74 100644
--- a/charf.c
+++ b/charf.c
@@ -518,7 +518,7 @@ void* handle_threads(void* arguments){
pthread_join(args->threads[i], NULL);
printf("In main: Thread %d has ended.\n", i);
}
- printf("All calculations finished.\n");
+ printf("All calculations finished.\n\n");
printf(args->message);
}
@@ -567,8 +567,14 @@ int main() {
do {
getLine(prmpt, buff, sz);
if( 0 == strcmp(buff,"q") || 0 == strcmp(buff,"quit") || 0 == strcmp(buff,"exit") ){
- abort = true;
- if(finished >= NUM_THREADS) user_input_cont = false;
+ if(finished < NUM_THREADS){
+ printf("Aborting calculations.\n");
+ abort = true;
+ }
+ else{
+ printf("Stopping program.\n");
+ user_input_cont = false;
+ }
}
else if( 0 == strcmp(buff,"r")) print_records(exponents,records_ratio,records_index);
else if( 0 == strcmp(buff,"t")*strcmp(buff,"p")){
@@ -578,6 +584,8 @@ int main() {
getLine("Enter file name:\n", buff, sz);
print_records_to_file(exponents,records_ratio,records_index,buff,format);
}
+ else printf("Command \"%s\" unrecognized.\n",buff);
+ printf("\n");
} while(user_input_cont);
/*Wait for thread handler thread to complete.*/