I am a beginner currently working on an assignment that has C++ open a text file containing data such as :

[253, 676, 114]
[527, 160, 277]
[364, 193, 169]
[246, 651, 378]
[536, 479, 695]
[569, 548, 83]
[117, 387, 543]
[294, 753, 702]
[651, 296, 284]
[600, 498, 114]
[201, 260, 629]
[686, 473, 375]
[234, 727, 89]
[447, 83, 730]
[521, 591, 300]
[279, 405, 227]
[686, 101, 448]
[559, 602, 283]
[75, 137, 170]
[430, 136, 527]
[111, 259, 219]
[280, 217, 707]
[433, 437, 194]
[165, 359, 643]
[398, 463, 614]

I am responsible for creating a program that will find the max and min of the data set provided.
I am having a really hard time finding a max and min since C++ is reading the square brackets and commas as integers. I have tried to approach it a few ways and can't seem to get the right answer. Can anyone can please help or set me in the right direction on how to approach this?

Can you read each line as a string, and then use a regex to ignore the brackets and commas and separate the 3 integers per line - and then work with those?

This seems to be a list of triples (coordinates?) and I’m not sure if you are looking for the minimum of all the numbers or some mathematical relationship in each of the items in the square brackets.
As this is a text file, you could use the input file stream operator >> to parse off characters (brackets and commas) and integers into your variables.
There are plenty of on-line tutorials you could find which would help with this.

This file presumably represents a list of somethings - the object oriented approach would be to have a class to represent whatever the [a,b,c] lines are and then define a function that will interpret a text line into internal parameters. You could use the >> get operator or simply loop through the characters yourself, confirming that braces and commas appear where expected whilst you decode the numerical parts of the string.

Be a part of the DaniWeb community

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