I have data in the following format in a file
( p1, p2 ) (p3, p4 ) ( p5, p6 )
How do i read this in C++, I can read a line and parse it , but I was looking for some C++ stl way to read this kind of format.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the format you want to represent the data in your program. One way is to have a
structwith a custom stream-extraction operator:As @Seth Carnegie demonstrates in an answer to a similar question, you can also use
INT_MAXto make sure you skip enough – however, usingstd::numeric_limits<std::streamsize>::max()would be even better.Then you can read all the contents of the file like this:
Here is a complete working example.