Conversion to non-scalar type

I've been browsing around google for a good amount of time and can't grasp what is going on. I'm a noob in my 1st semester of c++ and this is an assignment for class.
Lines 33 and 34 in main when i call two functions. I get error:
conversion from `suns_record*' to non-scalar type `suns_record' requested

Can someone please explain what is causing the error in dumb dumb terms? It would be much appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <iostream> // keyboard and screen I/O
#include <fstream>  // file I/O
#include <string>   // string class for C++ strings
#include <iomanip>  // formatted output support
using namespace std;

const int MAX_GAMES = 53;

struct suns_record   //Structure for Sun's calendar record
{   int month;  //Month game was played
    int day;      //Day the game was played
    char location;    //Home or away
    string team;      //team name
    int suns_score; //Phoenix's score
    int op_score;  //opponent's score
    int spread;  //difference in points
  
};     

void open_file(ifstream&); 
void read(ifstream&, suns_record[], int&); 
void sort(suns_record);
void print_out(suns_record);

int win_tot, los_tot, tie, road, home, winsum,lossum, index = 0;

int main()
{
    suns_record games[MAX_GAMES];
    ifstream suns_sheet;
    open_file(suns_sheet);
    read(suns_sheet, games, index);
    sort(games);
    print_out(games);
    
    system("pause");
    return 0;
}

void open_file(ifstream& suns_sheet)
{     
   string file;               // user-specified file name
   do
   {
        cout << "\n\n\tPhoenix Suns Calendar Record";
        cout << "\n\n\tEnter Suns record file name: ";
        //filename.flush();
        cin >> file;         // take in the file name (STUDENTS.DTA)
        suns_sheet.open(file.c_str());
        if(!suns_sheet && (file != "QUIT"))
             cout << "\tCan't open the file.  Please try again, or enter QUIT";
        }while(!suns_sheet && (file != "QUIT"));
   if (file == "QUIT")
   { 
       cout << "\n\n\t";
       exit(1);                      // end program if no file
   }
 return;
}    

void read(ifstream& suns_sheet, suns_record games[], int& index)
// read from the file into the array of records
{
   index=0;
   //int home,road,ws,ls,winsum,lossum;
   while(suns_sheet && index < MAX_GAMES)
   {
       suns_sheet >> games[index].month;
       suns_sheet >> games[index].day;
       suns_sheet >> games[index].location;
       suns_sheet >> games[index].team;
       suns_sheet >> games[index].suns_score;
       suns_sheet >> games[index].op_score;
       games[index].spread = games[index].suns_score - games[index].op_score;
       if(games[index].location == 'H')
           home++;
       else
           road++;
       if(games[index].spread > 0) 
       {
           winsum+= games[index].spread;
           win_tot++;
       }
       else if(games[index].spread < 0)
       {
           lossum+= games[index].spread;
           los_tot++;
       }
       else 
            tie++;
       index++;
   }
 index--;                        // adjust for late detection of eof
 return;
}  

void Sort(suns_record games[])
{
     char temp[15];
     char temp_b[15];
     suns_record temp_game;

     for(int i = 0; i < MAX_GAMES; i++)
     {
       strcpy(temp, games[i].team.c_str());
           for(int j = i+1; j <MAX_GAMES; j++)
           {
               strcpy(temp_b, games[j].team.c_str());
               if(strcmp (temp_b,temp) < 0)
               {
                    temp_game = games[i];
                    games[i] = games[j];
                    games[j] = temp_game;    
               }  
           }
     }
    
 return;
}

void print_out(suns_record games[])
{
     cout << fixed << showpoint << setprecision(1);
     cout << "\n\n\t\tPHOENIX SUNS STATS\n\n";
     cout << "\tTotal Wins\t Total losses\t #Home Games\t#Away Games\n";

     cout << "\t    " << win_tot;
     cout << "\t\t     " << los_tot;
     cout << "\t\t     " << home;
     cout << "\t\t    " << road  <<"\n\n";
          
     cout <<"\tAverageWinBy\t AverageLoseBy\t Win Percentage\n";
          
     cout << "\t   " << (float)winsum / win_tot;
     cout << "\t\t     " << (float)lossum / los_tot;
     cout << "\t     " << (float)win_tot/los_tot;
          
     cout << "\n\n\t";
     for(int i = 0; i<= MAX_GAMES;i++)
          cout << games[i].team << "\n\n";
     return;
      
}

The function declarations on lines 22 & 23 don't match the implementation at lines 97 & 121.
Thank You it works now.
Will there be other cases where it brings brings this error? What exactly is a scalar type and non scalar type?
http://en.wikipedia.org/wiki/Scalar_%28computing%29

There are many ways to attempt to do the same thing, just as there are may ways that a comma is commonly misplaced in the English language.

This, for example, will give you the same error:

sun_record a = new sun_record();

A novice may see that as "another case" but an experienced programmer and the compiler will not.

To be fair, it would be nice if the compiler would warn you that the function declaration did not match the definition. But the way the C++ language is specified, that is not really possible. All the compiler knew when it hit the line with the error is that you were attempting to pass a sun_record* to a function that was declared to take sun_record by value. That's the exact same thing that's happening in the example above.
Topic archived. No new replies allowed.