input problem

Discussion in 'C++' started by Kay, Sep 1, 2004.

  1. Kay

    Kay Guest

    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);
    Kay, Sep 1, 2004
    #1
    1. Advertising

  2. Kay

    Mike Wahler Guest

    "Kay" <> wrote in message
    news:...
    > 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
    Mike Wahler, Sep 1, 2004
    #2
    1. Advertising

  3. Kay wrote:

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





    --
    Karthik.
    Karthik Kumar, Sep 1, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Weng Tianxiang
    Replies:
    12
    Views:
    1,580
  2. ashutosh
    Replies:
    3
    Views:
    8,959
    Andrew Thompson
    Jun 16, 2005
  3. Guy
    Replies:
    5
    Views:
    2,797
    brucie
    Dec 13, 2003
  4. cjl
    Replies:
    1
    Views:
    10,480
    Michael Winter
    Oct 31, 2005
  5. Replies:
    1
    Views:
    458
Loading...

Share This Page