Is there any way to read a formatted string like this, for example :48754+7812=Abcs.
Let’s say I have three stringz X,Y and Z, and I want
X = 48754
Y = 7812
Z = Abcs
The size of the two numbers and the length of the string may vary, so I dont want to use substring() or anything like that.
Is it possible to give C++ a parameter like this
":#####..+####..=SSS.."
so it knows directly what’s going on?
A possibility is
boost::split(), which allows the specification of multiple delimiters and does not require prior knowledge of the size of the input:Or, using
sscanf():However, the limitiation here is that the maximum length of the string (
Z) must be decided before parsing the input.