type convertion

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);
}
 
M

Mike Wahler

Kay said:
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?

Did you not read the replies you already got?

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

input problem 2
input problem 2
Quene display 2
Convertion 1
getline and linked list problem 2
How to do that ? 1
Linked list inserting items from two different funcion 1
Access violation reading location 0

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top