C언어 구조체에서 불러와서 평균내는 함수 도와주세여
나빛
2023.04.01
#include iostream
using namespace std;
#include string
#include stdio.h
#include string.h
struct{
char name[20];
int year;
int score;} player[50];
int i, a, cs_a = 0;
int b=0,c=0;
int average(int q){
for (i = 0; i a; i++){
if (player[i].year==q){
b+= player[i].score;
c++;
}
}cout 평균 :; return b / c;
}
int main(){
int d;
cout 나이 :;
cin d;
average(d);
return 0;
}
이렇게 짜니까 제대로 함수가 작동을 안하는거같아요
strcmp는 int형에는 못쓰는거같고 ;
뭘 수정해야 제대로 작동하죠?
중간에 구조체에 집어넣는건 생략했어요