Oh yes.Finally I got it.Thank you a lottt Moschops.The worst thing is that my code wont be reusable, when I define the points.How can I make it to read from file instead?
EDIT [don't know why I wrote about output streams...] Well each of your vertices is a pair of doubles, so you must read two doubles to the file stream. If you want, you could put the number of vertices at the top of the file, but with a vector this shouldn't be necessary. Just keep reading pairs and checking for EOF.
Here's some example code; it opens the file someTextFile.txt and reads the values from it until there are none left to read. This should be enough to demonstrate the mechanics of reading from a file; it's up to you to work out how best to store the numbers and make sure that you deal with them appropriately. There are other ways to read from a file; this should get you started.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <fstream>
int main()
{
std::ifstream input("someTextFile.txt");
int a = 0;
while (input >> a)
{
if( input.eof() ) break;
std::cout << a << std::endl;
}
return 0;
}
I try it since yesterday, but It didnt work.So today I decided to make it with defined points.I Made it to read from the file, but I couldnt make a vector with the pairs..So if you can give me more specific advise on how to do it I will be very thankful.If you dont have time for me, Thank you for the help so far :)
This shows reading in values and putting them into elements of two vectors. The values are simply in the text file with a gap between each value. Nothing else.
I saw my mistake, I should have been very tired to miss "infile.open"...I have also some mistake in the calculations, but I am working at it now, and I think I will fix it.If I make it I will post the result here and will mark it as solved, for those after me.Thank you a lot for the help Xander and Moschops :)