im trying to make a project where i can access multiple companies, and inside of each company there can be multiple coments and ratings, and this is what i came up with:
#define COMPANY_INITIAL_SIZE 20
#define SEARCHES_INITIAL_SIZE 20
#define TEXT_MAX_SIZE 200
#define NAME_MAX_SIZE 50
#define EMAIL_MAX_SIZE 50
#define TITLE_MAX_SIZE 50
#define ADDRESS_MAX_SIZE 70
#define LOCATION_MAX_SIZE 70
#define CATEGORY_MAX_SIZE 30
#define NIF_MIN_SIZE 100000000
#define NIF_MAX_SIZE 999999999
enum category {
microCompany = 1, pmeCompany, macroCompany
};
enum state {
inactive, active
};
enum searchCamp {
nif, businessArea, nameLocation
};
enum comentState {
hidden,visible
};
typedef struct {
char title[TITLE_MAX_SIZE];
char text[TEXT_MAX_SIZE];
char userName[NAME_MAX_SIZE];
char userEmail[EMAIL_MAX_SIZE];
enum comentState states;
} Coment;
typedef struct {
int nota;
char userName[NAME_MAX_SIZE];
char userEmail[EMAIL_MAX_SIZE];
} Rating;
typedef struct {
int Nif;
char name[NAME_MAX_SIZE];
enum category categories;
int businessAreaCode;
enum state states;
char address[ADDRESS_MAX_SIZE];
char location[LOCATION_MAX_SIZE];
int postalCode;
int comentCounter,comentSize;
Coment coments;
int ratingCounter,ratingSize;
Rating ratings;
} Company;
typedef struct {
int counter, size;
Company *companies;
} Companies;
but after trying to insert coments in the companies it gives me this error: subscripted value is neither array nor pointer nor vector.
void insertComent(Companies *companies) {
int company, nif;
char title[TITLE_MAX_SIZE], text[TEXT_MAX_SIZE], name[NAME_MAX_SIZE], email[EMAIL_MAX_SIZE];
nif = getInt(NIF_MIN_SIZE, NIF_MAX_SIZE, "\nNIF [9 digits]: ");
company = verifyIfCompanyExists(*companies, nif);
if (company != -1) {
readString(title, TITLE_MAX_SIZE, "\nTitle: ");
strcpy(companies->companies[company].coments[companies->companies[company].comentCounter].title, title); //<- this is the line that gives the error.
readString(text, TEXT_MAX_SIZE, "\nTitle: ");
strcpy(companies->companies->coments.text, text);
readString(name, NAME_MAX_SIZE, "\nUserName: ");
strcpy(companies->companies->coments.userName, name);
readString(email, EMAIL_MAX_SIZE, "\nEmail: ");
strcpy(companies->companies->coments.userEmail, email);
}
}
i tried searching if what i was doing was possible but nothing that i got told me anything.