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" ...

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;
    }
}

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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.