'line' is an array, so you access its elements by using its indexes. line[0] and line[1], in this case.
inside each element, you made a
sf::Vertex. you can access its 'position' and then its 'x' and 'y' values.
so, to change them, you should use something like this:
line[0].position.x = 100;
or, if you want to change the vertex position in one line:
line[0].position = sf::Vector2f(100, 100);
You can create function that takes two vectors as parameters which are start and end of the line.
Then simply pass sf::Vertex array with vertices constructed from provided start and end positions to window's draw method
void draw_line(const sf::Vector2f& a, const sf::Vector2f&b)
{
sf::Vertex line[]=
{
sf::Vertex(a),
sf::Vertex(b)
};
window.draw(line ... )
}
draw_line(sf::Vector2f(0, 0), sf::Vector2f(10, 10));
the problem in this case is that you would be creating the line every iteration. may not be much for lines, but for most cases you create shapes and/or sprites just once and then, each iteration, just draw them.
and also the function is missing a reference to the window