type convertion

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

  1. Kay

    Kay Guest

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

  2. Kay

    Mike Wahler Guest

    "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
     
    Mike Wahler, Sep 1, 2004
    #2
    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. Replies:
    8
    Views:
    1,958
    Mike Treseler
    Feb 10, 2005
  2. isore
    Replies:
    0
    Views:
    555
    isore
    Jul 1, 2004
  3. MLyngsie
    Replies:
    2
    Views:
    887
    MLyngsie
    Oct 26, 2006
  4. kaikai
    Replies:
    4
    Views:
    274
    kaikai
    Jan 3, 2006
  5. Allen
    Replies:
    2
    Views:
    332
    Allen
    Dec 25, 2008
Loading...

Share This Page