Hello everyone, I'm trying to implement qsort on a struct with the double as a pivot: typedef struct{ char sequence[9]; int occurance; double prob; }tuple; ...... int compare (const void *x, const void *y){ if (x < y) return -1; if (x > y) return 1; else return 0; } ... qsort(x,k,sizeof(tuple),compare); Now I was trying to access members only to find that it doesn't work. int compare (const void *x, const void *y){ if (x.prob < y.prob) return -1; if (x.prob > y.prob) return 1; else return 0; } error: request for member ‘prob’ in something not a structure …

Member Avatar
Member Avatar
+0 forum 2

I have created a basic object oriented database of a list of shoes containing the shoe name, number and shoe size. I am trying to sort the list of shoes alphabetially by name and by shoe size. I have the following code: Shoes.h: #include <iostream> #include <fstream> #include <string> #ifndef Shoes_Shoes_h #define Shoes_Shoes_h using namespace std; class Shoe { public: //Constructors Shoe(); Shoe(string Name_, double ShoeSize_, int Number_); //Destructor ~Shoe(); //Getters string getName() const; double getShoeSize() const; int getNumber() const; //Setters void setName(const string Name_); void setShoeSize(const double ShoeSize_); void setNumber(const int Number_); //Variables string Name; double ShoeSize; int Number; …

Member Avatar
Member Avatar
+0 forum 13

The End.