I have a file which contains pixel coordinates in the following format :
234 324
126 345
264 345
I don't know how many pairs of coordinates I have in my file.
How can I read them into a vector<Point>
file? I am a beginner at using reading functions in C++.
I have tried this but it doesn't seem to work :
vector<Point> iP, iiP;
ifstream pFile, rFile;
pFile.open("D:\\MATLAB\\WORKSPACE_MATLAB\\pData.txt");
rFile.open("D:\\MATLAB\\WORKSPACE_MATLAB\\rData.txt");
string rBuffer, pBuffer;
Point rPoint, pPoint;
while (getline(pFile, pBuffer))
{
getline(rFile, rBuffer);
sscanf(rBuffer.c_str(), "%d %d", rPoint.x, rPoint.y);
sscanf(pBuffer.c_str(), "%d %d", pPoint.x, pPoint.y);
iP.push_back(pPoint);
iiP.push_back(rPoint);
}
I receive some odd memory errors. Am I doing something wrong? How can I fix my code so that it can run?