Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > type convertion

Reply
Thread Tools

type convertion

 
 
Kay
Guest
Posts: n/a
 
      09-01-2004
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);
}


 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      09-01-2004

"Kay" <> wrote in message
news:...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do type convertion for template class? Allen C++ 2 12-25-2008 11:58 AM
Type convertion when doing arimetic on intergers. MLyngsie VHDL 2 10-26-2006 08:12 AM
type convertion between template kaikai C++ 4 01-03-2006 03:54 PM
type convertion of an unconstrained output in a port map ygrugni@hotmail.com VHDL 8 02-10-2005 06:53 PM
Convertion php to asp.net : PB lecture fichier .ini isore ASP .Net 0 07-01-2004 05:52 PM



Advertisments