如何从文件读取点

zeb*_*bra 2 c++

我正在阅读以下格式的文件:

12, 10
15, 20
2, 10000
Run Code Online (Sandbox Code Playgroud)

我希望以x,y点的形式阅读这些内容.我已经开始了,但我不知道从哪里开始......这是我到目前为止所拥有的:

ifstream input("points.txt");
string line_data;

while (getline(input, line_data))
{
    int d;
    std::cout << line_data << std::endl;
    stringstream line_stream(line_data);
    while (line_stream >> d)
    {
        std::cout << d << std::endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何以x,y整数读取这些行中的每一行?

Ker*_* SB 6

说:

int a, b; char comma;

if (line_stream >> a >> comma >> b)
{
  // process pair (a, b)
}
Run Code Online (Sandbox Code Playgroud)