0

Hi dudes, does anyone know where is the problem this my code:

void CMyListBox::loadSources(CMyListBox::eInputMode eMode,const std::vector<wchar_t>& coll) {
	
	wchar_t *pBuffer=new wchar_t[coll.size()];
	std::copy(coll.begin(),coll.end(),pBuffer);
	wchar_t zodis[20];
	
	while (swscanf_s(pBuffer,L"%s",zodis,20)) 
		MessageBox(zodis);
	
}

the imput(pBuffer) is this string "šešios žąsys su šešiais žąsiukais."
swscanf_s only keeps reading the same word "šešios" ...

Edited by cppgangster: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Narue
0

swscanf_s only keeps reading the same word "šešios" ...

Because pBuffer doesn't change. Unlike a file stream where the get pointer is managed for you, the scanf family works with a pointer to char and you must manage moving the pointer around to suit your needs. For example:

#include <iostream>

using namespace std;

int main()
{
    char *p = "this is a test";
    char buf[5];
    int n = 0;

    while (sscanf(p, "%4s%n", buf, &n) == 1) {
        puts(buf);
        p += n;
    }
}
0

Thanks for your help.
Is is possible that if I copy text file from Ubuntu linux to usb memory then to Win 7 and then I will try to read it will create some problems?

0

Is is possible that if I copy text file from Ubuntu linux to usb memory then to Win 7 and then I will try to read it will create some problems?

Yes, very possible due to differences in file system formatting.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.