input problem

K

Kay

If my input is an integer, how can I compare w/ the queue
(mode shows as below) in order to display the context containing the
integer that I input ?



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;

--> mode QueueInsert( ReCuMo, name, cuisine, mode);
 
M

Mike Wahler

Kay said:
If my input is an integer, how can I compare w/ the queue
(mode shows as below) in order to display the context containing the
integer that I input ?



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;

--> mode QueueInsert( ReCuMo, name, cuisine, mode);

Your question is rather vague, and you don't give enough
information. We don't know what your function 'QueInsert()'
does, what the definition of type 'mode' is, etc. Also
note that that last line isn't a valid prototype or
function call.


-Mike
 
K

Karthik Kumar

Kay said:
If my input is an integer, how can I compare w/ the queue
(mode shows as below) in order to display the context containing the
integer that I input ?

The code does not compile and the Q appears to be a little bit vague.
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());

Unless there is a compelling reason on your part to use char * ( as
in when interfacing with some C modules), try to go for string STL. The
API and the code would look much more cleaner and would have relatively
less buffer exploits compared to the one using char * .

//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;

--> mode QueueInsert( ReCuMo, name, cuisine, mode);
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top