c++ - Invalid conversion from 'const char*' to 'char' -


i working on miscellaneous theater seating program! starting progress through c++, can't figure out error keep on getting in coding. trying code way input "*"s character character, me build function display seating chart movie theater. pretty close finishing function called readseating... though there clear problems it. can debug programs pretty efficiently, can't figure 1 out. please take @ code, feel program, , let me have ideas. please keep answers simple; again, i'm no master @ c++

p.s.

sorry showing whole code... first post... didn't know include, not to; , wanted people able feel program testing themselves... again!

/*  * program built team of students * local movie theaters sell tickets *  * file: main.cpp * author(s): * *  * created on april 15, 2013, 11:10 */   #include <cstdlib> #include <vector> #include <string> #include <fstream> #include <iostream> #include <cctype> #include <iomanip>  using namespace std;  //function prototypes void title_card(); void seating_prices(); void seating_chart(); void pick_seating(); void purchase_history(); void quit(); void update_file(); void show_menu(); void is_digit(int&); void admin_menu(); void edit_seating_prices(); void edit_seating(); void quit_to_original(); void purchase_history_admin();  int readseating (char, vector<char>&); //reads seatingchart.txt int readprices(string, vector<double>&); //reads seatingprices.txt vector<double> prices(15); //for seatprices.txt vector<char> seating(450); //for seatingchart.txt    //actual program int main() { title_card(); //calls title page  readseating("seatingchart.txt", seating); //reads seatingchart.txt readprices("seatprices.txt", prices); //reads seatprices.txt show_menu(); //shows introductory menu  system ("pause"); return 0; }     //************************************************************** // definition of showmenu function. shows introductory menu* // , controls user ends in program.             * //**************************************************************   void show_menu() { int choice; string password;    cout << "welcome our theater program! made person" << endl;   cout << "who looking seating, purchasing ticket, and" << endl;   cout << "searching other miscellaneous things... hope" << endl;   cout << "you enjoy program!" << endl << endl;   cout << "below list of options user can choose from:" << endl << endl;   cout << "1.\tseating prices" << endl;   cout << "2.\tpick seating" << endl;   cout << "3.\tpurchase history" << endl;   cout << "4.\tquit" << endl << endl;   cout << "enter choice... (1-4): ";   cin >> choice;    //secret administrator access   if (choice == 219){      system ("cls");      cout << "enter administrator password: ";      cin >> password;       if (password == "sterilegorilla")         admin_menu();      else {         system ("cls");         show_menu();           }   }     is_digit(choice);//is_digit function doesn't work atm     while (choice < 1 || choice > 4){         cout << endl << "you have entered invalid choice!" << endl;         cout << "enter choice... (1-4): ";         cin >> choice;         is_digit(choice); //is_digit function doesn't work atm             if (choice == 219){                system ("cls");                cout << "enter administrator password: ";                cin >> password;                     if (password == "sterilegorilla")                       admin_menu();                         else {                            system ("cls");                            show_menu();                            }                                 }      }    switch (choice) {          case 1:               seating_prices();           case 2:               pick_seating();           case 3:               purchase_history();           case 4:               quit();               }  }      //************************************************************** // definition of seating_prices function. displays  * // user, seatprices.txt                                        * //**************************************************************   void seating_prices(){ system ("cls"); cout << "the current seating prices are:" << endl << endl; (int count = 0; count < 4; count++){ cout << " " << setprecision(4) << showpoint <<  prices[count] << " | row " << (count + 1) <<                         endl; } (int count = 4; count < prices.size(); count++){ cout << "  " << setprecision(3) << showpoint <<  prices[count] << " | row " << (count + 1) << endl; } cout << endl; system ("pause"); system ("cls"); show_menu(); }     //************************************************************** // definition of pick_seating function. displays       * // current seating chart , allows user pick seat* //**************************************************************   void pick_seating(){  //not finished system ("cls"); int row_choice; int seat_choice;  cout << "the current seating chart is:" << endl;   //display seating chart     //picking seat cout << "enter row number in (1-15): ";              cin >> row_choice; while (row_choice < 1 || row_choice > 15){       cout << endl << "you have entered invalid row number!" << endl;       cout << "enter row number in (1-15): ";       cin >> row_choice;       }  cout << "enter seat number have (1-30): "; cin >> seat_choice; while (seat_choice < 1 || seat_choice > 30){       cout << endl << "you have entered invalid seat number!" << endl;       cout << "enter seat number have (1-30): ";       cin >> seat_choice;       }  cout << "congratulations! have picked seat!" << endl << endl; system ("pause"); system ("cls"); show_menu(); }     //************************************************************** // definition of purchase_history function. displays   * // current total sum of movie ticket purchases         * //**************************************************************   void purchase_history(){         //not finished  system ("cls");  system ("pause");  system ("cls");  show_menu(); }    //************************************************************** // definition of quit function. allows user quit the* // program entirely                                            * //**************************************************************   void quit(){  update_file();  exit(0);  }    //************************************************************** // definition of is_digit function. designed make    * // possible enter integers when asked integers     * //**************************************************************    void is_digit(int & input){      //not working atm  if (isdigit(input)){      return;      }  if (isalpha(input)){      cout << endl << "you have entered invalid data type!" << endl;      cout << "enter choice... (1-4): ";      cin >> input;      }  if (isspace(input)){      cout << endl << "you have entered invalid data type!" << endl;      cout << "enter choice... (1-4): ";      cin >> input;      }      }     //************************************************************** // definition of update_file function. designed update  * // seating chart upon leaving pick_seating function    * //**************************************************************    void update_file(){  //not finished   //this function supposed  //update seating chart  //upon exit of pick_seating function  }     //************************************************************** // definition of admin_menu function. displays         * // administrator-based menu if user knows code , password* //**************************************************************   void admin_menu(){    system ("cls");   int choice = 0;    cout << "hello! administrator version";   cout << endl << "of theatre program; used editing purposes." << endl << endl;   cout << "below list of options administrator can choose from:" << endl << endl;   cout << "1.\tedit seating prices" << endl;   cout << "2.\tedit seating" << endl;   cout << "3.\tpurchase history" << endl;   cout << "4.\tquit original" << endl;   cout << "5.\tquit program" << endl << endl;   cout << "enter choice... (1-5): ";   cin >> choice;          while (choice < 1 || choice > 5){         cout << endl << "you have entered invalid choice!" << endl;         cout << "enter choice... (1-5): ";         cin >> choice;         }    switch (choice) {          case 1:               edit_seating_prices();           case 2:               edit_seating();           case 3:               purchase_history_admin();           case 4:               quit_to_original();           case 5:               quit();          }   }    //************************************************************** // definition of edit_seating function. administrator-only * // function edit seating chart                          * //**************************************************************    void edit_seating(){             //not finished  system ("cls");  system ("pause");  system ("cls");  admin_menu();  }     //************************************************************** // definition of edit_seating function. administrator-only * // function edit prices of seats.                   * // in turn, overwrite seatprices.txt                 * //**************************************************************    void edit_seating_prices(){    //not finished  system ("cls");  system ("pause");  system ("cls");  admin_menu();  }    //************************************************************** // definition of purchase_history_admin function.          * // administrator-only function designed show admin      * // total sum of ticket sales... not editable                   * //**************************************************************   void purchase_history_admin(){  system ("cls");  system ("pause");  system ("cls");  admin_menu();  }    //************************************************************** // definition of quit_to_original function. administrator- * // function designed return admin original program  * //**************************************************************   void quit_to_original(){  system ("cls");  show_menu();  }     //************************************************************** // definition of read_file function. reads seatprices.txt  * // , stores pre-determined prices vector named    * // prices.                                                     * //**************************************************************    int readprices(string myfile, vector<double>& vect) {  //input file ifstream seatprices;                     seatprices.open(myfile.c_str());   //if file cannot found if (!seatprices)  cout << "cannot find file!" << endl;   (int index = 0; index < vect.size(); index++){     seatprices >> vect[index];   //reading file "seatprices.txt"     }  seatprices.close();  //closes file return 0; }     //************************************************************** // definition of readseating function. reads text file   * // seating chart in it.                                 * //**************************************************************    int readseating(char myfile, vector<char>& vect){           //not close finishing   //input file ifstream seatingchart; seatingchart.open(myfile);  //if file cannot found if (!seatingchart) cout << "cannot find file!" << endl;  (int index = 0; index < vect.size(); index++){     seatingchart >> vect[index];  //reading file "seatingchart.txt"     }  seatingchart.close(); //closes file return 0; }         //************************************************************** // definition of title_card function. starts program   * // title card, showing little introductory title      * //**************************************************************   void title_card(){  cout << endl << endl << endl << endl;  cout << "\t\t" << "************************************************\n";  cout << "\t\t" << "*               theater seating!               *\n";  cout << "\t\t" << "*                                              *\n";  cout << "\t\t" << "*     program created team of 3     *\n";  cout << "\t\t" << "*     students small theaters sell     *\n";  cout << "\t\t" << "*                 more tickets                 *\n";  cout << "\t\t" << "*                                              *\n";  cout << "\t\t" << "*              team of students:               *\n";  cout << "\t\t" << "*                                              *\n";  cout << "\t\t" << "*                *************                 *\n";  cout << "\t\t" << "*                 ***********                  *\n";  cout << "\t\t" << "*                *************                 *\n";  cout << "\t\t" << "*                                              *\n";  cout << "\t\t" << "************************************************\n";  cout << endl << endl;  system ("pause");  system ("cls");  } 

first of (i think intended write)

int readseating (char, vector<char>&); 

should be

int readseating (char*, vector<char>&);                     ^^^ 

expect lvalue first argument. means can possibly assign to.

however calling as

readseating("seatingchart.txt", seating); 

by passing temporary first argument. complier wants know not modify inorder let pass temporary. can tell wnot modify declaring function like.

int readseating (const char*, vector<char>&);                  ^^^^ 

same goes for

int readseating(char myfile, vector<char>& vect) 

to

int readseating(const char* myfile, vector<char>& vect) 

i suggest should go ahead , change them strings.

int readseating (string, vector<char>&); int readseating(string myfile, vector<char>& vect) 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -