I have a vector of strings "moves"

std::vector<string> moves;

and the Chars:

char fromX, toX, fromY, toY;

I use:

sscanf(moves[0], "%c%c %c%c", &fromX, &fromY, &toX, &toY);

and Compiler says:

error: no matching function for call to 'sscanf(std::string&, const char[10], char*, char*, char*, char*)'

What is the problem???

sscanf() is a C function, not c++, and knows nothing about c++ containers like std::string, you have to pass it a character array. sscanf(xx.c_str(), "%c%c %c%c", &fromX, &fromY, &toX, &toY);

Note that sscanf isn't an ordinary method or built-in function, but a very special construction in Pike.

That link is not talking about C or C++ languages.

In the code snippet you posted above, what string does xx contain? There is probably another way to do what you want without using sscanf(). Post an example of moves[0]

In the code snippet you posted above, what string does xx contain? There is probably another way to do what you want without using sscanf(). Post an example of moves[0]

Was an error. its edited in the first post.

Yes I noticed that you changed the first parameter from xx to moves[0]. So what does moves[0] contain anyway?

contain a string

vector <string> moves;

This article has been dead for over six months. Start a new discussion instead.