wxString str = "Hello, world!"; wxString sub = str.BeforeFirst(','); // sub is now "Hello"
wxString str = "apple pie"; wxString sub = str.BeforeFirst('x'); // sub is now "apple pie"In this example, we create a wxString object called str and assign it the value "apple pie". We call BeforeFirst() with the 'x' character as an argument, but since 'x' doesn't appear in str, the function returns a copy of the original string. Library: wxWidgets.