0

I have a function for adding a new profile as below.

bool Main_window::add_new_profile(char* f_name_entered)
{
     char* l_name_entered;

     // skipped some portion

     bool m_status = throw_m_dialog("Enter New Profile Name",l_name_entered);

     // skipped some portion

     if(m_status)

     // skipped rest of the function

The throw_m_dialog function in header file

bool throw_m_dialog(char* f_label, char* f_name);

The throw_m_dialog function

bool throw_m_dialog(char* f_label, char* f_name)
{
    Glib::ustring l_text;

    //skipped some portion

    g_input_dialog_label->set_text(f_label);

    // skipped some portion

    if(l_response==Gtk::RESPONSE_OK)
      {
        l_text=g_input_text->get_text();
        f_name=(char*)l_text.data();
        return true;
       }

     // skipped the cancel part

My problem is that i get some unreadable characters. I guess i am reading the address. How do i update the profile name from the throw_dialog function?

Majid Khan
  • 111
  • 2
  • 14
  • What's up with all the `char*`? you are coding gtkmm; `Glib::ustring` is your friend. – Mark Sep 04 '13 at 13:58
  • To answer your question, though, I believe you want `l_text.c_str()` not `l_text.data()`: http://stackoverflow.com/questions/194634/string-c-str-vs-data – Mark Sep 04 '13 at 14:01

0 Answers0