hi it may sound very easy I need a hint first of all I know how to break a string into integers but what I got is string like this "2001 , 2002 , 2003 ,2005,2006-2015" a I need this string break into separate years and if there is a dash `-` between years I need to store all years from for example 2006 to 2015.
Its one fuction from a bigger program and I dont know how to do this If u can point me in right direction
You might want to first tidy up the string to remove any spaces - I took this data directly from the original question.
Also the <cstring> library has the strtok function with similar but different parsing capability, for example you could split the string at either a comma or a hyphen.
When you have the integer neatly in a string, the atoi() function can turn it into a numeric value if required.