I have a coding assignment that I'm having trouble on. The language that I am coding in is C. I'm trying to pass an array of structs into a function, and then print out a certain member of the struct, to make sure I'm accessing them correctly. However, I keep coming across this error and I'm not at all sure why. Project3_soccer.c: In function ‘findPlayer’:Project3_soccer.c:108:17: error: expected expression before ‘playerData’printf("%d",playerData[i].playerNumber);                  ^~~~~~~~~~   My code is below: #include <stdio.h>#include <stdbool.h> typedef struct playerData_struct {int playerNumber;char playerName[100];double playerRating;} playerData; int findPlayer(int whichPlayer, const playerData jerseyNumbers[], int maxJersyCount); bool jerseyValid(int playerJerseyNumber); bool ratingValid(double playerRating); void printPlayer(playerData* player);   int main(void) {int i = 0;int j = 0;int index = 0;double rating = 0;struct playerData_struct players[10];char menuOp = 'x';while (menuOp != 'q') {// Menuprintf("\nMENU\n");printf("a - Add a new player\n");printf("u - Update player information\n");printf("r - Remove a player from the roster\n");printf("d - Display player information\n");printf("p - Print the full roster\n");printf("s - Print \"Star\" players\n");printf("q - Quit\n"); printf("\nChoose an option: ");scanf(" %c", &menuOp); switch (menuOp) { case 'a':for (j = 0;j < 10;j++) {players[j].playerNumber = j + 3;printf("%d\n",players[j].playerNumber);}index = findPlayer(7,players,j);printf("%d",index);/*if (j == 0) {printf("Enter player jersey number: ");scanf("%d",&player[j].playerNumber);if (jerseyValid(player[j].playerNumber) == 1) {printf("Enter player first or nick name: ");scanf("%s",player[j].playerName);printf("Enter player rating: ");scanf("%lf",&player[j].playerRating);}else {break;}}*/case 'u': case 'r': case 'd': case 'p':printf("ROSTER\n------\n");for (i = 0;i < 10;i++) {if ((players[i].playerNumber > 0) && (players[i].playerNumber) < 99) {printf("%s\n",players[i].playerName);printf("%d\n",players[i].playerNumber);printf("%lf\n",players[i].playerRating);printf("\n");}}case 's':printf("Enter minimum STAR rating: ");scanf("%lf",&rating);printf("MY STARS\n--------\n");for (i = 0;i < 10;i++) {if (players[i].playerRating > rating) {printf("%s\n",players[i].playerName);printf("%d\n",players[i].playerNumber);printf("%lf\n",players[i].playerRating);printf("\n");}}break;case 'q':break;default:;}}return 0;} int findPlayer(int whichPlayer, const playerData jerseyNumbers[], int maxJersyCount) {int index = 0;printf("%d",playerData[i].jerseyNumbers);return index;} bool jerseyValid(int playerJerseyNumber) {if ((playerJerseyNumber > 0) && (playerJerseyNumber < 100)) {return true;}else {return false;}} bool ratingValid(double playerRating) {if ((playerRating >= 0) && (playerRating <= 100)) {return true;}else {return false;}}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

I have a coding assignment that I'm having trouble on. The language that I am coding in is C. I'm trying to pass an array of structs into a function, and then print out a certain member of the struct, to make sure I'm accessing them correctly. However, I keep coming across this error and I'm not at all sure why.

Project3_soccer.c: In function ‘findPlayer’:
Project3_soccer.c:108:17: error: expected expression before ‘playerData’
printf("%d",playerData[i].playerNumber);
                  ^~~~~~~~~~

 

My code is below:

#include <stdio.h>
#include <stdbool.h>

typedef struct playerData_struct {
int playerNumber;
char playerName[100];
double playerRating;
} playerData;

int findPlayer(int whichPlayer, const playerData jerseyNumbers[], int maxJersyCount);

bool jerseyValid(int playerJerseyNumber);

bool ratingValid(double playerRating);

void printPlayer(playerData* player);

 

int main(void) {

int i = 0;
int j = 0;
int index = 0;
double rating = 0;
struct playerData_struct players[10];

char menuOp = 'x';

while (menuOp != 'q') {
// Menu
printf("\nMENU\n");
printf("a - Add a new player\n");
printf("u - Update player information\n");
printf("r - Remove a player from the roster\n");
printf("d - Display player information\n");
printf("p - Print the full roster\n");
printf("s - Print \"Star\" players\n");
printf("q - Quit\n");

printf("\nChoose an option: ");
scanf(" %c", &menuOp);

switch (menuOp) {

case 'a':

for (j = 0;j < 10;j++) {
players[j].playerNumber = j + 3;
printf("%d\n",players[j].playerNumber);
}
index = findPlayer(7,players,j);
printf("%d",index);
/*
if (j == 0) {
printf("Enter player jersey number: ");
scanf("%d",&player[j].playerNumber);

if (jerseyValid(player[j].playerNumber) == 1) {
printf("Enter player first or nick name: ");
scanf("%s",player[j].playerName);

printf("Enter player rating: ");
scanf("%lf",&player[j].playerRating);
}
else {
break;
}
}*/
case 'u':

case 'r':

case 'd':

case 'p':
printf("ROSTER\n------\n");
for (i = 0;i < 10;i++) {
if ((players[i].playerNumber > 0) &&
(players[i].playerNumber) < 99) {

printf("%s\n",players[i].playerName);

printf("%d\n",players[i].playerNumber);

printf("%lf\n",players[i].playerRating);
printf("\n");
}
}
case 's':
printf("Enter minimum STAR rating: ");
scanf("%lf",&rating);

printf("MY STARS\n--------\n");

for (i = 0;i < 10;i++) {
if (players[i].playerRating > rating) {

printf("%s\n",players[i].playerName);

printf("%d\n",players[i].playerNumber);

printf("%lf\n",players[i].playerRating);
printf("\n");
}
}
break;

case 'q':
break;

default:
;

}
}
return 0;
}

int findPlayer(int whichPlayer, const playerData jerseyNumbers[], int maxJersyCount) {
int index = 0;

printf("%d",playerData[i].jerseyNumbers);

return index;
}

bool jerseyValid(int playerJerseyNumber) {
if ((playerJerseyNumber > 0) && (playerJerseyNumber < 100)) {
return true;
}
else {
return false;
}
}

bool ratingValid(double playerRating) {
if ((playerRating >= 0) && (playerRating <= 100)) {
return true;
}
else {
return false;
}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY