//--------------------------------------
// console.cpp ---
#include <wx/string.h>
#include <wx/crt.h> // shoudl be include here , other wise will report error like this
/* console.cpp:5:3: 错误:‘wxPuts’ was not declared in this scope; did you mean ‘puts’?
5 | wxPuts(wxT("A wxWidgets console application"));
| ^~~~~~
*/
int main(int argc, char **argv)
{
// printf("\n\rlocale is %s",setlocale(LC_ALL,NULL));//输出一下语言环境
wxString str1 = wxT("Linux");
wxString str2 = wxT("operatin");
wxString str3 = wxT("system");
wxString str = str1 + wxT(" ") + str2 + wxT(" ") + str3;
//wxPuts(str);//这种写法,中文无法输出
wxPuts(str.ToStdWstring());//这种写法中文才能正确输出
wxPuts(wxT("A wxWidgets console application"));
}
//-----------------------------------------------------------
g++ console.cpp `wx-config --cxxflags --libs` -o widgetTest
g++ addition.cpp `wx-config --cxxflags --libs` -o outfun
be careful with the ` ` is different with ' '
//-------------------------------------------------
// formatted.cpp
#include <wx/string.h>
#include <wx/crt.h>
int main(int argc, char* argv[])
{
int flowers = 21;
wxString str;
str.Printf(wxT("There are %d red roses."), flowers);
wxPuts(str);
}
-----------------------------------------------------
g++ formatted.cpp `wx-config --cxxflags --libs` -o outformat
---
./outformat
There ar 21 red roses.