I have to read coordinates from a file in c in order to calculate the distance between two points.
How to read the following input from a file?
(25, 4) (1, -6)
(2 ,3) (2,34)
You can use your file as it is but you are going to need kind of messy String Processing. In order to get the individual numbers you have to get rid of the brackets and the comma..
Rather I would suggest you to change the way you save the points to your file.
rather than putting the points [in your file] like this:
(25, 4) (1, -6)
Put them like this:
25 4 1 -6
Then you can simply say:
fscanf(fp,"%d%d%d%d,&x1,&y1,&x2,&y2);
To get the two points.