Albrecht Schlosser wrote:
> On 10.07.2016 03:04 Svets wrote:
>> I have also tried if(ted2->buffer()->text() =="") which doesn't make
>> any difference so I'm not sure how to test for an empty text editor and
>> buffer.
>>
>> void load_callback(Fl_Widget* wid, void* data)
>> {
>> if(buf2->text()=="")
>> {
>> fl_alert("No Data");
>> }
>>
>> }
>
> You can't test two strings for identity with '=='. This comparison tests
> if the two pointers to the strings are equal.
But he can check a const char* for beeing empty:
if (buf2->text()== nullptr || *buf2->text()== 0)
Because most FLTK text widgets doesn't return a nullptr (NULL, 0) when
empty, it is sufficient to check for the delimiter at first position:
if (*buf2->text()== 0) // checks for empty const char*