I have input string in shape of:polygons=[(4,5),(6,8),(5,3),(11.4,6);(3,8),(2,9),(1,2)],each semicolon tells me 1polygon entered user can input up to 100 polygons and 100 points in each polygon i want to store the x- coordinates of all points in 2D array how can i do that in c++? User can input any value for the points
A 100x100 array of integers is only 40kbytes, so that's perfectly feasible in most environments. Just loop through the input keeping one index for the current polygon and one for the current point. Or you may be better advised to use linked lists for the polygons and the points in each polygon if the potential size limits are increased... 100% overhead on the actual points, but no space wasted for unused slots?
i want to store the x- coordinates of all points in 2D array
Why only x? Why not store the x AND y coordinates?
Your question is difficult to answer as we don't know your current C++ skill level. Storing x AND Y doubles the memory size for a 100 x 100 array to 80K, assuming each integer is 4 bytes (likely, but not guaranteed), which if you are using a modern machine withg multiple gigs of RAM, isn't much (again, likely, but not guaranteed). If you create it on the "heap" rather than the "stack", you're much less likely to run out of memory.
But these might be new terms for you, so please do detail your experience level. It's pointless to point out an STL method if you're unfamiliar with STL, just as it's pointless to explain how to tokenize the input and use stringstreams if that's all new to you too. Ditto all the threads out there where the OP mentions "Oh yeah, we're not allowed to use vectors or pass by reference or use classes" in the fourth post rather than the first.
Thus, please do elaborate more regarding your experience level, your computer resources, what is to be done with this data, etc., etc. Anything pertinent. Particularly where precisiely you are stuck, because no one STARTS with a program like this so I assume you know how to do some of it and are stuck at a particular problem. Makes no sense to explain how to parse the string if you've already done that.