I tried the program and this appeared many times (warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat])
My goal is to make a game where a player is required to type a set of words from a file but the words should appear only one by one and the user should type every time the word is displayed. I'm also trying to make a stopwatch timer that starts as soon as the player chooses the option start game but I think it's hard so my main goal for now is to make the game without the timer. The function in the bottom should make a file which contains highscores.
Code:
#include<stdio.h>
#include<time.h>
int main(){
FILE *fp;
char go, player[30];
char word[15],typed[15];
clock_t start_t, end_t, total_t;
int choice, i=0;
printf("Welcome to the fastest typer game!\n");
printf("Input name of player:");
scanf("%s",player);
printf("Are you ready?\n\t1. Play Game\n\t2. High Scorers\n\t3. Exit");
scanf("%i",&choice);
switch (choice){
case 1: start_t = clock();
for(i =0;i<10000000; i++)
{
}
//File Read
fp=fopen("words.txt","r");
do{
fscanf(fp,"%s \n", word[i]);
do{
printf("Type the word:\n %s", word[i]);
scanf("%s",typed[i]);
}while(typed[i]!=word[i]);
i++;
}while(!feof(fp));
fclose(fp);
end_t = clock();
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
printf("Total time: %f\n", total_t );
highScore(player);
case 2: fp=fopen("highscore.text","r");
fscanf(fp,"%s \n", player);
printf("%s", player);
case 3: break;
default: printf("Not in the choices, try again: ");
scanf("%i",choice);
}
}
void highScore(char player){
//File Write
FILE *fp;
fp=fopen("highscore.text","a");
fprintf(fp,"%s\n", player);
fclose(fp);
}