K
Kay
This function is loaded a txt file and add these data in a queue. Hence,
it is allowed to input an integer. I want to use this integer to call
back the suitable node in the queue. The problem is how to convert char*
to int. OR it have an alternative way to solve this problem. Mode(as
below ) is storing an integer. Can it use other way to load the txt file?
/* Load the restaurant name, cuisine name
and operation mode add it in a queue */
void RestCuisineModeQueue( istream& is, Queue * ReCuMo ){
string temp_name, temp_cuisine, temp_mode;
/* get the restaurant name, cuisine name and the operation mode
from the gourmet txt file */
while ( getline(is, temp_name, ';') && getline(is, temp_cuisine, ';') &&
getline(is, temp_mode, '\n') ){
char *name, *cuisine, *mode;
//change type of name of restaurant from string to char
name = new char[temp_name.length() + 1 ];
strcpy( name, temp_name.c_str());
//change type of name of cuisine from string to char
cuisine = new char[temp_cuisine.length() + 1 ];
strcpy( cuisine, temp_cuisine.c_str());
//change type of operation mode from string to char
mode = new char[temp_mode.length() + 1 ];
strcpy( mode, temp_mode.c_str());
//cout << name << cuisine << mode << endl;
QueueInsert( ReCuMo, name, cuisine, mode);
}
it is allowed to input an integer. I want to use this integer to call
back the suitable node in the queue. The problem is how to convert char*
to int. OR it have an alternative way to solve this problem. Mode(as
below ) is storing an integer. Can it use other way to load the txt file?
/* Load the restaurant name, cuisine name
and operation mode add it in a queue */
void RestCuisineModeQueue( istream& is, Queue * ReCuMo ){
string temp_name, temp_cuisine, temp_mode;
/* get the restaurant name, cuisine name and the operation mode
from the gourmet txt file */
while ( getline(is, temp_name, ';') && getline(is, temp_cuisine, ';') &&
getline(is, temp_mode, '\n') ){
char *name, *cuisine, *mode;
//change type of name of restaurant from string to char
name = new char[temp_name.length() + 1 ];
strcpy( name, temp_name.c_str());
//change type of name of cuisine from string to char
cuisine = new char[temp_cuisine.length() + 1 ];
strcpy( cuisine, temp_cuisine.c_str());
//change type of operation mode from string to char
mode = new char[temp_mode.length() + 1 ];
strcpy( mode, temp_mode.c_str());
//cout << name << cuisine << mode << endl;
QueueInsert( ReCuMo, name, cuisine, mode);
}