Browse Source

Added loading progress bar

main
fdlt3859 2 years ago
parent
commit
622b54fe9d
  1. 33
      src/main/quizproject.c
  2. 2
      src/main/quizproject.h

33
src/main/quizproject.c

@ -4,6 +4,7 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h>
#include "quizproject.h" #include "quizproject.h"
char answers[NUM_QUESTIONS] = {'B', 'A', 'A','B','A'}; char answers[NUM_QUESTIONS] = {'B', 'A', 'A','B','A'};
@ -1814,7 +1815,35 @@ void displayCredits(void) {
printf("- Frau Monika Schak (Lecturer: Programming-1 in C)\n"); printf("- Frau Monika Schak (Lecturer: Programming-1 in C)\n");
} }
int main() {
void progress_bar(int percentage)
{
printf("\r[");
for (int i = 0; i < 50; i++)
{
if (i < (percentage / 2))
{
printf(">");
}
else
{
printf(" ");
}
}
printf("] %d%%", percentage);
fflush(stdout);
}
void v_progress_bar(int argc, char *argv[]){
for (int i = 0; i <= 100; i++)
{
progress_bar(i);
usleep(100000);
}
printf("\n");
}
int main(int argc, char *argv[]) {
int choice; int choice;
printf("Welcome to the Game Menu!\n"); printf("Welcome to the Game Menu!\n");
printf("\t\t----------------------------\n\n"); printf("\t\t----------------------------\n\n");
@ -1855,6 +1884,7 @@ int main() {
printf("8. Exit\n"); printf("8. Exit\n");
printf("Enter your choice: "); printf("Enter your choice: ");
scanf("%d", &choice); scanf("%d", &choice);
v_progress_bar(argc,argv);
switch(choice) { switch(choice) {
case 1: case 1:
@ -1897,6 +1927,7 @@ int main() {
char jump_key; char jump_key;
scanf(" %c", &jump_key); scanf(" %c", &jump_key);
jump_key = toupper(jump_key); jump_key = toupper(jump_key);
v_progress_bar(argc,argv);
} }
} }
feedbackForm(); feedbackForm();

2
src/main/quizproject.h

@ -28,6 +28,8 @@ void displayCredits(void);
void v_factorlie(void); void v_factorlie(void);
void v_guessingGame(void); void v_guessingGame(void);
void v_guessTheWord(char word[], char guessed[]); void v_guessTheWord(char word[], char guessed[]);
void progress_bar(int percentage);
void v_progress_bar(int argc, char *argv[]);
void million_instructions(); void million_instructions();
void million_exit(int million_a); void million_exit(int million_a);

Loading…
Cancel
Save