#include <iostream> #include <string> #include <array> using namespace std; stru
ID: 3551340 • Letter: #
Question
#include <iostream>
#include <string>
#include <array>
using namespace std;
struct playerType{
string name;
int Runs;
int Hits;
};//ends struct for playerType
void getplayerInfo(struct playerType,const int);
int main(){
const int playerSize = 5;
playerType playerArray[5];
getplayerInfo(playerArray, playerSize); // I keep getting an error for this line. It says cannot convert
//arguement 1 from playerType[5] to 'playerType'
return 0;
}//ends main
void getplayerInfo(struct playerType playerArray[],const int playerSize){
for (int i = 0; i < playerSize; i++){
cin >> playerArray[i].name;
cin >> playerArray[i].Runs;
cin >> playerArray[i].Hits;
}
}//ends
Explanation / Answer
#include <iostream>
#include <string>
//#include <array>
using namespace std;
struct playerType{
string name;
int Runs;
int Hits;
};//ends struct for playerType
void getplayerInfo(struct playerType[],const int);//modified code
int main(){
const int playerSize = 5;
playerType playerArray[5];
getplayerInfo(playerArray, playerSize); // I keep getting an error for this line. It says cannot convert
//arguement 1 from playerType[5] to 'playerType'
return 0;
}//ends main
void getplayerInfo(struct playerType playerArray[],const int playerSize){
for (int i = 0; i < playerSize; i++){
cin >> playerArray[i].name;
cin >> playerArray[i].Runs;
cin >> playerArray[i].Hits;
}
}//ends
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.