I am trying to run this program and keep getting the same errors. What does missing terminating character mean and how can I fix these issues in my code? Everything runs fine on Repl for me. I copied and pasted to Linux and now I got all of these errors.
RPS.c:162:10: warning: missing terminating " character
RPS.c: In function âprintResultsâ:
RPS.c:162: error: missing terminating " character
RPS.c:163: error: expected expression before â%â token
RPS.c:163:9: warning: missing terminating " character
RPS.c:163: error: missing terminating " character
RPS.c:164: error: expected â;â before â}â token
code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void flushScanf(void);
int compareInputs(char);
char getInput();
void printResults(int, int, int);
int main(void) {
char userInput;
int flag=1;
int myWins= 0;
int pcWins= 0;
int ties= 0;
int result;
printf("Let’s play a game of Rock/Paper/Scissors \n");
do{
userInput = getInput();
if(userInput == 'Q' || userInput == 'q') {
printResults(myWins, pcWins, ties);
printf("\nThank you for playing!");
flag =0;
}else if(userInput == 'R' || userInput == 'r'){
userInput = 'r';
}else if(userInput == 'P' || userInput == 'p'){
userInput = 'p';
}else if(userInput == 'S' || userInput == 's'){
userInput = 's';
}else{
printf("Error, Please try again\n ");
}
result = compareInputs(userInput);
switch(result){
case 1:
myWins++;
break;
case 2:
pcWins++;
break;
case 3:
ties++;
break;
}
}while(flag==1);
return 0;
}
char getInput(void){
char userInput;
printf("\nEnter R, P, S, or Q (for quit):");
scanf("%c", &userInput);
flushScanf();
return userInput;
}
char check(char input){
}
int compareInputs(char userInput){
srand(time(NULL));
int pc = (rand()%3)+1;
if (pc==1 && userInput == 'r'){
printf("You picked Rock, the computer picked Rock.\n");
printf("It's a tie.\n");
return 3;
} else if(pc==1 && userInput == 's'){
printf("You picked Scissors, the computer picked Rock.\n");
printf("Rock breaks Scissors, you lose!\n");
return 2;
}else if(pc==1 && userInput == 'p'){
printf("You picked Paper, the computer picked Rock.\n");
printf("Paper covers rock, you win!\n");
return 1;
}else if (pc==2 && userInput == 'r'){
printf("You picked Rock, the computer picked Paper.\n");
printf("Paper covers rock, you lose.\n");
return 2;
} else if (pc==2 && userInput == 's'){
printf("You picked Scissors, the computer picked Paper.\n");
printf("Scissors cuts Paper, you win!\n");
return 1;
} else if (pc==2 && userInput == 'p'){
printf("You picked Paper, the computer picked Paper.\n");
printf("It's a tie.\n");
return 3;
} else if (pc==3 && userInput == 'r') {
printf("You picked Rock, the computer picked Scissors.\n");
printf("Rock breaks Scissors, you win!\n");
return 1;
} else if (pc==3 && userInput =='s'){
printf("You picked Scissors, the computer picked Scissors.\n");
printf("It's a tie\n");
return 3;
} else if (pc==3 && userInput == 'p'){
printf("You picked Paper, the computer picked Scissors.\n");
printf("Scissors cuts paper, You lose!\n");
return 2;
}
return 4;
}
void printResults(int myWins, int pcWins, int ties){
printf("\nYou won %d times, the computer won %d times, and it was a tie %d times", myWins, pcWins, ties);
}
void flushScanf(void) {
char c = getchar();
while (c != '\n' && c != EOF) {
c = getchar();
}
}
What I have tried:
Retyped quotations and other punctuation marks in case its because the editor uses a different character system.