Need some help with passing structure pointers

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
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
struct record{
           int id;
           int cost;
           double price;
           char descr[37];
           
           
    };
    
struct mliat{
       int id;
       int cost;
       };
       
void lox(mliat m[],int count){
     int min;
     for (int j = 0; j < count-1; j++) {
            min=j;
            for (int i = j+1; i < count; i++) {
                   if (m[i]<m[min]) {
                     min = i;
                    }
             }
      } 
}
int sortByCost(const char *inFile, int *array,int count)
{
                 
                 ifstream file;
                 file.open(inFile, ios::binary);
                 record data;
                 mliat cyka;
                 mliat *ptr;
                 ptr=new mliat[count];
                 char *records,*cost;
                 int length,error=0,i;
                 if (!file)
                 {
                        cerr << "Error opening file. Program aborting." << endl;
                        return(-2);
                  }
                 
                 if ( count >0){
                 
                      
                 
                 for(i=0;i<=count;i++)
                       file.read(reinterpret_cast<char *>(&data), sizeof(data));
                       ptr[i].id=data.id;
                       ptr[i].cost=data.cost;
                      
                 } 
                 lox(&ptr[count],count);
                 cout<<cyka.id<<endl;
                 cout<<cyka.cost;
                 file.clear();
                 file.seekg(sizeof(data) * count, ios::beg);
                 file.close();
                 return 0;
                 
}

the compiler gives out the error
no match for 'operator<' in '*((+(((unsigned int)i) * 8u)) + m) <*((+(((unsigned int)min) * 8u)) + m)' for the line f (m[i]<m[min]) in the function lox
for some reason, the code is really unfinished by the way, i just need to figure out wats causing this error
Last edited on
Topic archived. No new replies allowed.