FLTK logo

[fltk.general] Why do I need to convert a string to a string for Fl_Input

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Why do I need to convert a string to a string for Fl_Input roger tunnicliffe Oct 05, 2022  
  I have the following definitions:-

 Fl_Input            *win2_unitprice;
  win2_unitprice        = new Fl_Input(x+50,y+200,100,20,"Unit Price..:");

and the following code:-

double z;
.
.
  string s1 = to_string(z);
  string s2 = s1.c_str();
// win2_unitprice->value(s1);
    win2_unitprice->value(s1.c_str());

If I uncomment line 3 I get the following error:-
error: no matching function for call to ‘Fl_Input::value(std::__cxx11::string&)’
   win2_unitprice->value(s1);

but if i look at the data I see that:-
s1 holds the address of the data 0x31 0x2e 0x31 0x30 ....
and 
s2 holds the address of the data 0x31 0x2e 0x31 0x30 ....

so why do I need to use c_str() to make this work ??

Breakpoint 1, w2_browser_Callback (w=0x7dc1b0, data="" at fV3.04.cxx.267
(gdb) x/8b &s1
0x7fffffffdc30:             0x40 0xdc 0xff 0xff 0xff 0x7f 0x00 0x00
(gdb) x/8b 0x7fffffffdc40
0x7fffffffdc40:                0x31 0x2e 0x31 0x30 0x30 0x30 0x30 0x30
(gdb) x/8b &s2
0x7fffffffdc50:                0x60 0xdc 0xff 0xff 0xff 0x7f 0x00 0x00
(gdb) x/8b 0x7fffffffdc60:
0x7fffffffdc60:                0x31 0x2e 0x31 0x30 0x30 0x30 0x30 0x30

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/918550c6-aee1-4f96-8b59-bcc65d12bc8fn%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.