I basically got two problems, I get a control reaches end of non void function warning in my function even though I got a return.
And secondly my get char in the while loop near the end of the main function is not being evaluated, the program just ends after I enter a team letter, it wasn't doing this earlier when I used scanf instead of get char, but scanf was giving me character constant too long warning.
Code:
//ASSIGNMENT 1
#include <stdio.h>
#define RETURN '\n'
#define PRINT_SCORE 1
char gameScore (char s);
int main (int argc, char **argv) {
char team;//Team
char s;
char teamA;
char teamB;
printf ("Which team to serve? A or B?\n");
scanf ("%c", &team);
if ( team == 'A') {
printf ("Team A to serve:\n");
}
else if ( team == 'B'){
printf ("Team B to serve:\n");
}
else{
printf ("Incorrect entry, try again\n");
return 0;
}
while ((s = getchar()) != '\n') {
if (gameScore( s ) == PRINT_SCORE){
printf("%d-%d\n", teamA, teamB);
}
}
return (0);
}
char gameScore (char s){
int teamA;
int teamB;
teamA = 0;
teamB = 0;
if(s == 'A'){
teamA = teamA+15;
}
else if(s == 'B'){
teamB = teamB+15;
}
else if(s == 'S'){
return(PRINT_SCORE);
}
}
Any help would be greatly appreciated, cheers