How do you fix c++ expected primary expression error? -


so, i'm new c++ programming, , assignment teacher having create app. started coding , came with. tried compile code in codeblocks , gave me quite few errors:

error: expected primary-expression before 'petprofile' in int main() in case 1 through case 3 of switch statement.

error: no match 'operator=' in '(*(petprofile + ((sizetype) ((unsigned int)petindex) * 4u))))->pet::vaccnames = nextvaccn' comes line of code: petprofile[petindex]->vaccnames = nextvaccn;

same kind of error for: petprofile[petindex]->vaccdates = nextvaccd;

and, petprofile[petindex]->timebetween = nexttimediff;

any appreciated, thank you.

//constant  const int maxnumofpet = 8;  //functions  void newprofile(pet petprofile);  void updateexist(pet petprofile);  void viewpetfile(pet petprofile);  void howtouse();  int main() {     int usersoption;     int* optionpointer = &usersoption;     pet petprofile[maxnumofpet];      //the while loop start here, display start menu, ,  direct different functions     //until user selects exit.         {         //displays different options user.         cout << "\n1) create new pet profile" << endl;         cout << "2) update existing profile" << endl;         cout << "3) view pet profile" << endl;         cout << "4) how use" << endl;         cout << "5) quit" << endl;          cout << "please pick option wish do." << endl;         cin >> *optionpointer;          switch (usersoption)         {         case 1:             newprofile(pet petprofile);             break;         case 2:             updateexist(pet petprofile);             break;         case 3:             viewpetfile(pet petprofile);             break;         case 4:             howtouse();             break;         case 5:             cout << "bye, bye!";             return 0;         }   //end of switch statement     } while (usersoption >= 1 || usersoption < 5);      return 0; }  void newprofile(pet *petprofile[], const int maxnumofpet) {     int changeop;     int nextvaccd;     char correct;     double nexttimediff;     string nextvaccn;     int petindex = 0;      while (petindex <= maxnumofpet)     {         //check if pet empty         while (petprofile[petindex]->petnames.empty())         {             //will receive users input following topics, , add   vectors.              cout << "please enter pet's name, or enter 0 quit. " <<   endl;             if ( cin.peek() == '\n' )                 cin.ignore();              string nextpetn;             getline(cin, nextpetn);              if (nextpetn == "0")                 return;              //will add element vector petnames , save users input it.             petprofile[petindex]->petnames = nextpetn;              cout << "please enter type of animal have:" << endl;             if ( cin.peek() == '\n' )                 cin.ignore();              string nextanimalt;             getline(cin, nextanimalt);              //will add element vector animaltype , save users input it.             petprofile[petindex]->animaltype = nextanimalt;              cout << "please enter name of vaccine pet has got: " << endl;             cin >> nextvaccn;              //will add element vector vaccnames , save users input it.             petprofile[petindex]->vaccnames = nextvaccn;              cout << "please enter date " << nextvaccn << " given, in format mmddyyyy." << endl;             cin >> nextvaccd;              //will add element vector vaccdates , save users input it.             petprofile[petindex]->vaccdates = nextvaccd;              cout << "please enter time difference between each administration of vaccine: " << endl;             cin >> nexttimediff;              //will add element vector timebetween , save users input it.             petprofile[petindex]->timebetween = nexttimediff;              //recap information entered, , change if necessary.             cout << "\nso far entered: " << endl;             cout << nextpetn << endl;             cout << nextanimalt << endl;             cout << nextvaccn << endl;             cout << nextvaccd << endl;             cout << nexttimediff << endl;              cout << "is information correct?" << endl;             cout << "answer t if true or f if false" << endl;             cin >> correct;              if (correct == 'f' || correct == 'f')             {                 cout << "what wish change: " << endl;                 cout << "1) " << nextpetn << endl;                 cout << "2) " << nextanimalt << endl;                 cout << "3) " << nextvaccn << endl;                 cout << "4) " << nextvaccd << endl;                 cout << "5) " << nexttimediff << endl;                 cin >> changeop;                  switch (changeop)                 {                 case 1:                     cout << "please enter pets' name: " << endl;                     getline(cin, nextpetn);                     break;                  case 2:                     cout << "please enter type of animal have:" << endl;                     getline(cin, nextanimalt);                     break;                  case 3:                     cout << "please enter name of vaccines pet has got: " << endl;                     getline(cin, nextvaccn);                     break;                  case 4:                     cout << "please enter date " << nextvaccn << " given, in format mmddyyyy." << endl;                     cin >> nextvaccd;                     break;                  case 5:                     cout << "please enter time difference between each administration of vaccine: " << endl;                     cin >> nexttimediff;                     break;                 } //end switch             } //end if statement         }//end second while loop     } //end first while loop      petindex++; } //end newprofile function 

your function declaration

void newprofile(pet petprofile); 

does not correspond definition

void newprofile(pet *petprofile[], const int maxnumofpet) 

also, line(s)

case 1:         newprofile(pet petprofile); 

should be

case 1:         newprofile(petprofile); // no pet here, same other case-s 

check other function declarations match definitions.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -