how use wxSscanf for string include the white spaces

Discussion about CodeLite development process and patches
vsfai
CodeLite Enthusiast
Posts: 11
Joined: Tue Jan 10, 2012 11:50 pm
Genuine User: Yes
IDE Question: c++
Contact:

how use wxSscanf for string include the white spaces

Post by vsfai »

Hello,

I was wondering if there was a way to include the white spaces in a string.

wxString xxx = wxT("1 test word");

wxChar *naa = NULL;
int num = 0;

if( na ) delete [] naa;
naa = new wxChar[10];

wxSscanf(xxx, wxT("%d %[^\0]s"),&num, naa);
//i tested also this: %[^ ]s and %[ a-zA-Z0-9+*/_]
wxString yyy(naa);
wxMessageBox(naa);

I need have in naa = "test word"";
However, this doesn't include the 'space' character or any other white
spaces. Is there a way I can include the 'space' character rather than skip
in.

Thanks in advance.

BR, VSfai
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how use wxSscanf for string include the white spaces

Post by eranif »

vsfai wrote:Hello,

I was wondering if there was a way to include the white spaces in a string.

wxString xxx = wxT("1 test word");

wxChar *naa = NULL;
int num = 0;

if( na ) delete [] naa;
naa = new wxChar[10];

wxSscanf(xxx, wxT("%d %[^\0]s"),&num, naa);
//i tested also this: %[^ ]s and %[ a-zA-Z0-9+*/_]
wxString yyy(naa);
wxMessageBox(naa);

I need have in naa = "test word"";
However, this doesn't include the 'space' character or any other white
spaces. Is there a way I can include the 'space' character rather than skip
in.

Thanks in advance.

BR, VSfai
Please ask wxWidgets related questions in the appropriate forum (i.e. NOT in codelite's forum)

http://forums.wxwidgets.org/

Eran
Make sure you have read the HOW TO POST thread
Post Reply